-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.spec.js
63 lines (54 loc) · 1.88 KB
/
app.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { bootstrap } from 'aurelia-bootstrapper';
import { StageComponent } from 'aurelia-testing';
import { PLATFORM } from 'aurelia-pal';
import { Alternate1ValueConverter } from '../../src/alternate1';
import { Alternate2ValueConverter } from '../../src/alternate2';
import { configure as configureLib } from '../../src/index';
function configure(config) {
return config.use
.standardConfiguration()
.feature(configureLib);
}
describe('Stage Component', function () {
let component;
async function checkMessage(expected) {
const msgElement = component.element.querySelector('#message');
try {
await component.waitForElement(`#message.${expected}`, { present: true, timeout: 1000 });
} finally {
expect([...msgElement.classList]).toEqual(expect.arrayContaining([expected]));
}
}
describe('comp1', function () {
beforeEach(async function () {
Alternate1ValueConverter.reset();
component = StageComponent
.withResources(PLATFORM.moduleName('parent1'))
.inView('<parent1></parent1>');
component.bootstrap(configure);
await component.create(bootstrap);
});
afterEach(() => component.dispose());
it('should render message', async function () {
await checkMessage('msg-text1');
component.viewModel.toggle();
await checkMessage('msg-text0');
});
});
describe('comp2', function () {
beforeEach(async function () {
Alternate2ValueConverter.reset();
component = StageComponent
.withResources(PLATFORM.moduleName('parent2'))
.inView('<parent2></parent2>');
component.bootstrap(configure);
await component.create(bootstrap);
});
afterEach(() => component.dispose());
it('should render message', async function () {
await checkMessage('msg-text1');
component.viewModel.toggle();
await checkMessage('msg-text0');
});
});
});