Skip to content
This repository has been archived by the owner on Jun 1, 2022. It is now read-only.

Commit

Permalink
Try flushing queues explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
tomtomau committed Mar 25, 2019
1 parent 7156b43 commit 186aaca
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
26 changes: 26 additions & 0 deletions skeleton-esnext-webpack/test/helper/flush-queue.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Container, TaskQueue } from 'aurelia-framework';

export function flushQueue() {
let taskQueue = Container.instance.get(TaskQueue);

if (!taskQueue) {
throw new Error('TaskQueue not available in container');
}

taskQueue.flushTaskQueue();
}

export function flushMicroQueue() {
let taskQueue = Container.instance.get(TaskQueue);

if (!taskQueue) {
throw new Error('TaskQueue not available in container');
}

taskQueue.flushMicroTaskQueue();
}

export function flushQueues() {
flushQueue();
flushMicroQueue();
}
7 changes: 6 additions & 1 deletion skeleton-esnext-webpack/test/unit/foo.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {bootstrap} from 'aurelia-bootstrapper';
import {StageComponent} from 'aurelia-testing';
import {PLATFORM} from 'aurelia-pal';
import { flushQueues } from '../helper/flush-queue';

describe('FooComponent', () => {
let component;
Expand Down Expand Up @@ -28,9 +29,13 @@ describe('FooComponent', () => {
expect(component.viewModel.bar).toBeFalsy();
})

it('clicking on the button should toggle bar', () => {
it('clicking on the button should toggle bar', async () => {
const button = document.querySelector('#button');
button.click();

flushQueues();
await Promise.resolve();

expect(component.viewModel.bar).toBeTruthy();

// This line fails
Expand Down

0 comments on commit 186aaca

Please sign in to comment.