1 | import { StageComponent, ComponentTester } from '../src/component-tester';
|
2 | import { bootstrap } from 'aurelia-bootstrapper';
|
3 |
|
4 | describe('SampleCustomComponent', () => {
|
5 | let component: ComponentTester;
|
6 |
|
7 | beforeEach(() => {
|
8 | component = StageComponent
|
9 | .withResources('dist/test/test/resources/my-component')
|
10 | .inView('<my-component first-name.bind="firstName"></my-component>')
|
11 | .boundTo({ firstName: 'Bob' });
|
12 | });
|
13 |
|
14 | it('should render first name', done => {
|
15 | component.create(bootstrap)
|
16 | .then(() => {
|
17 | const nameElement = document.querySelector('.firstName') as Element;
|
18 | expect(nameElement.innerHTML).toBe('Bob');
|
19 | done();
|
20 | })
|
21 | .catch(error => {
|
22 | fail(error);
|
23 | done();
|
24 | });
|
25 | });
|
26 |
|
27 | afterEach(() => {
|
28 | component.dispose();
|
29 | });
|
30 | });
|
31 |
|
32 | describe('SampleCustomAttribute', () => {
|
33 | let component: ComponentTester;
|
34 |
|
35 | beforeEach(() => {
|
36 | component = StageComponent
|
37 | .withResources('dist/test/test/resources/my-attribute')
|
38 | .inView('<div my-attribute.bind="color">Bob</div>')
|
39 | .boundTo({ color: 'blue' });
|
40 | });
|
41 |
|
42 | it('should set the background color to provided color', done => {
|
43 | component.create(bootstrap)
|
44 | .then(() => {
|
45 | expect((component.element as HTMLElement).style.backgroundColor).toBe('blue');
|
46 | done();
|
47 | })
|
48 | .catch(error => {
|
49 | fail(error);
|
50 | done();
|
51 | });
|
52 | });
|
53 |
|
54 | afterEach(() => {
|
55 | component.dispose();
|
56 | });
|
57 | });
|