Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/aurelia-testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export * from './compile-spy';
export * from './view-spy';
export * from './component-tester';
export * from './wait';
export * from './update-bindings';

export function configure(config: FrameworkConfiguration) {
config.globalResources([
Expand Down
9 changes: 9 additions & 0 deletions src/update-bindings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Container, TaskQueue } from 'aurelia-framework';

export function updateBindings() {
const tq: TaskQueue = Container.instance.get(TaskQueue);

if (tq) {
tq.flushMicroTaskQueue();
}
}
19 changes: 19 additions & 0 deletions test/doc-samples.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { StageComponent, ComponentTester } from '../src/component-tester';
import { bootstrap } from 'aurelia-bootstrapper';
import { updateBindings } from '../src/update-bindings';

describe('SampleCustomComponent', () => {
let component: ComponentTester;
Expand All @@ -24,6 +25,24 @@ describe('SampleCustomComponent', () => {
});
});

it('should render new first name after update using helper', done => {
component.create(bootstrap)
.then(() => {
const nameElement = document.querySelector('.firstName') as Element;
expect(nameElement.innerHTML).toBe('Bob');

component.viewModel.firstName = 'TheBuilder';
updateBindings();

expect(nameElement.innerHTML).toBe('TheBuilder');
done();
})
.catch(error => {
fail(error);
done();
});
});

afterEach(() => {
component.dispose();
});
Expand Down