Get unit tests working again

pull/6920/head
Robin Munn 5 years ago
parent 50cc07ec93
commit e005bd7f03

@ -1,5 +1,5 @@
import { run_all, Queue } from './utils'; import { run_all, Queue } from './utils';
import { set_current_component } from './lifecycle'; import { get_current_component, set_current_component } from './lifecycle';
export const dirty_components = new Queue<any>(); export const dirty_components = new Queue<any>();
export const intros = { enabled: false }; export const intros = { enabled: false };
@ -34,6 +34,11 @@ export function add_flush_callback(fn) {
const seen_callbacks = new Set(); const seen_callbacks = new Set();
export function flush() { export function flush() {
let current_component = null;
try {
current_component = get_current_component()
} catch {}
do { do {
// first, call beforeUpdate functions // first, call beforeUpdate functions
// and update components // and update components
@ -65,6 +70,8 @@ export function flush() {
render_callbacks.length = 0; render_callbacks.length = 0;
} while (dirty_components.length); } while (dirty_components.length);
set_current_component(current_component);
while (flush_callbacks.length) { while (flush_callbacks.length) {
flush_callbacks.pop()(); flush_callbacks.pop()();
} }

Loading…
Cancel
Save