Skip to content

Commit fe1581e

Browse files
committed
chore(tests): simplify spec files for easier testing
1 parent 1c5cd9b commit fe1581e

File tree

6 files changed

+51
-87
lines changed

6 files changed

+51
-87
lines changed

addon/ng2/blueprints/class/files/__path__/__name__.spec.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
/* tslint:disable:no-unused-variable */
2+
13
import {
2-
describe,
3-
ddescribe,
4-
expect,
5-
iit,
6-
it
4+
beforeEach, beforeEachProviders,
5+
describe, ddescribe, xdescribe,
6+
expect, it, iit, xit,
7+
async, inject
78
} from '@angular/core/testing';
89
import {<%= classifiedModuleName %>} from './<%= fileName %>';
910

Original file line numberDiff line numberDiff line change
@@ -1,46 +1,20 @@
1+
/* tslint:disable:no-unused-variable */
2+
3+
import { By } from '@angular/platform-browser';
4+
import { DebugElement } from '@angular/core';
5+
16
import {
2-
beforeEach,
3-
beforeEachProviders,
4-
describe,
5-
expect,
6-
it,
7-
inject
7+
beforeEach, beforeEachProviders,
8+
describe, ddescribe, xdescribe,
9+
expect, it, iit, xit,
10+
async, inject
811
} from '@angular/core/testing';
9-
import { ComponentFixture, TestComponentBuilder } from '@angular/compiler/testing';
10-
import { Component } from '@angular/core';
11-
import { By } from '@angular/platform-browser';
12+
1213
import { <%= classifiedModuleName %>Component } from './<%= dasherizedModuleName %>.component';
1314

1415
describe('Component: <%= classifiedModuleName %>', () => {
15-
let builder: TestComponentBuilder;
16-
17-
beforeEachProviders(() => [<%= classifiedModuleName %>Component]);
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) => {
16+
it('should create an instance', () => {
17+
let component = new <%= classifiedModuleName %>Component();
2418
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-
}));
19+
});
3520
});
36-
37-
@Component({
38-
selector: 'test',
39-
template: `
40-
<<%= selector %>></<%= selector %>>
41-
`,
42-
directives: [<%= classifiedModuleName %>Component]
43-
})
44-
class <%= classifiedModuleName %>ComponentTestController {
45-
}
46-
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,16 @@
1+
/* tslint:disable:no-unused-variable */
2+
13
import {
2-
async,
3-
beforeEachProviders,
4-
describe,
5-
ddescribe,
6-
expect,
7-
iit,
8-
it,
9-
inject
4+
beforeEach, beforeEachProviders,
5+
describe, ddescribe, xdescribe,
6+
expect, it, iit, xit,
7+
async, inject
108
} from '@angular/core/testing';
11-
import { ComponentFixture, TestComponentBuilder } from '@angular/compiler/testing';
12-
import { provide, Component } from '@angular/core';
139
import { <%= classifiedModuleName %> } from './<%= dasherizedModuleName %>.directive';
1410

15-
@Component({
16-
selector: 'test-component',
17-
template: `<div <%= dasherizedModuleName %>></div>`
18-
})
19-
class TestComponent {}
20-
2111
describe('<%= classifiedModuleName %> Directive', () => {
22-
beforeEachProviders((): any[] => []);
23-
24-
it('should ...', async(inject([TestComponentBuilder], (tcb:TestComponentBuilder) => {
25-
return tcb.createAsync(TestComponent).then((fixture: ComponentFixture<any>) => {
26-
fixture.detectChanges();
27-
});
28-
})));
12+
it('should create an instance', () => {
13+
let directive = new <%= classifiedModuleName %>();
14+
expect(directive).toBeTruthy();
15+
});
2916
});

addon/ng2/blueprints/ng2/files/__path__/app/app.component.spec.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
/* tslint:disable:no-unused-variable */
2+
13
import {
2-
beforeEachProviders,
3-
describe,
4-
expect,
5-
it,
6-
inject
4+
beforeEach, beforeEachProviders,
5+
describe, ddescribe, xdescribe,
6+
expect, it, iit, xit,
7+
async, inject
78
} from '@angular/core/testing';
89
import { AppComponent } from './app.component';
910

Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1+
/* tslint:disable:no-unused-variable */
2+
13
import {
2-
beforeEachProviders,
3-
describe,
4-
expect,
5-
inject,
6-
it
4+
beforeEach, beforeEachProviders,
5+
describe, ddescribe, xdescribe,
6+
expect, it, iit, xit,
7+
async, inject
78
} from '@angular/core/testing';
89
import { <%= classifiedModuleName %>Pipe } from './<%= dasherizedModuleName %>.pipe';
910

1011
describe('Pipe: <%= classifiedModuleName %>', () => {
11-
beforeEachProviders(() => [<%= classifiedModuleName%>Pipe]);
12-
13-
it('should transform the input', inject([<%= classifiedModuleName %>Pipe], (pipe: <%= classifiedModuleName %>Pipe) => {
14-
expect(pipe.transform(true)).toBe(null);
15-
}));
12+
it('create an instance', () => {
13+
let pipe = new <%= classifiedModuleName %>Pipe();
14+
expect(pipe).toBeTruthy();
15+
});
1616
});

addon/ng2/blueprints/service/files/__path__/__name__.service.spec.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
/* tslint:disable:no-unused-variable */
2+
13
import {
2-
beforeEachProviders,
3-
it,
4-
describe,
5-
expect,
6-
inject
4+
beforeEach, beforeEachProviders,
5+
describe, ddescribe, xdescribe,
6+
expect, it, iit, xit,
7+
async, inject
78
} from '@angular/core/testing';
89
import { <%= classifiedModuleName %>Service } from './<%= dasherizedModuleName %>.service';
910

0 commit comments

Comments
 (0)