|
1 | 1 | import {
|
2 |
| - async, |
| 2 | + beforeEach, |
3 | 3 | beforeEachProviders,
|
4 | 4 | describe,
|
5 |
| - ddescribe, |
6 | 5 | expect,
|
7 |
| - iit, |
8 | 6 | it,
|
9 |
| - inject |
| 7 | + inject, |
10 | 8 | } from '@angular/core/testing';
|
11 | 9 | import { ComponentFixture, TestComponentBuilder } from '@angular/compiler/testing';
|
| 10 | +import { Component } from '@angular/core'; |
| 11 | +import { By } from '@angular/platform-browser'; |
12 | 12 | import { <%= classifiedModuleName %>Component } from './<%= dasherizedModuleName %>.component';
|
13 | 13 |
|
14 | 14 | describe('Component: <%= classifiedModuleName %>', () => {
|
| 15 | + let builder: TestComponentBuilder; |
| 16 | + |
15 | 17 | beforeEachProviders(() => [<%= classifiedModuleName %>Component]);
|
16 |
| - |
17 |
| - it('should create the component', inject([<%= classifiedModuleName %>Component], (component: <%= classifiedModuleName %>Component) => { |
18 |
| - expect(component).toBeTruthy(); |
19 |
| - })); |
| 18 | + beforeEach(inject([TestComponentBuilder], function (tcb: TestComponentBuilder) { |
| 19 | + builder = tcb; |
| 20 | + })); |
| 21 | + |
| 22 | + it('should inject the component', inject([<%= classifiedModuleName %>Component], |
| 23 | + (component: <%= classifiedModuleName %>Component) => { |
| 24 | + expect(component).toBeTruthy(); |
| 25 | + })); |
| 26 | + |
| 27 | + it('should create the component', inject([], () => { |
| 28 | + return builder.createAsync(<%= classifiedModuleName %>ComponentTestController) |
| 29 | + .then((fixture: ComponentFixture<any>) => { |
| 30 | + let query = fixture.debugElement.query(By.directive(<%= classifiedModuleName %>Component)); |
| 31 | + expect(query).toBeTruthy(); |
| 32 | + expect(query.componentInstance).toBeTruthy(); |
| 33 | + }); |
| 34 | + })); |
20 | 35 | });
|
| 36 | + |
| 37 | +@Component({ |
| 38 | + selector: 'test', |
| 39 | + template: ` |
| 40 | + <<%= selector %>></<%= selector %>> |
| 41 | + `, |
| 42 | + directives: [<%= classifiedModuleName %>Component] |
| 43 | +}) |
| 44 | +class <%= classifiedModuleName %>ComponentTestController { |
| 45 | +} |
| 46 | + |
0 commit comments