Skip to content

Commit

Permalink
chore(tests): update specs with TestBed
Browse files Browse the repository at this point in the history
Close #1766
Close #1846
  • Loading branch information
filipesilva committed Aug 26, 2016
1 parent 339af33 commit 48a695e
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/* tslint:disable:no-unused-variable */

import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { addProviders, async, inject } from '@angular/core/testing';
import { TestBed, async } from '@angular/core/testing';
import { <%= classifiedModuleName %>Component } from './<%= dasherizedModuleName %>.component';

describe('Component: <%= classifiedModuleName %>', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* tslint:disable:no-unused-variable */

import { addProviders, async, inject } from '@angular/core/testing';
import { TestBed, async } from '@angular/core/testing';
import { <%= classifiedModuleName %> } from './<%= dasherizedModuleName %>.directive';

describe('Directive: <%= classifiedModuleName %>', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* tslint:disable:no-unused-variable */

import { TestBed, async } from '@angular/core/testing';
import <%= classifiedModuleName %>Module from './<%= dasherizedModuleName %>.module';

describe('<%= classifiedModuleName %>Module', () => {
Expand Down
33 changes: 23 additions & 10 deletions addon/ng2/blueprints/ng2/files/__path__/app/app.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
/* tslint:disable:no-unused-variable */

import { addProviders, async, inject } from '@angular/core/testing';
import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';

describe('App: <%= jsComponentName %>', () => {
beforeEach(() => {
addProviders([AppComponent]);
TestBed.configureTestingModule({
declarations: [
AppComponent
],
});
});

it('should create the app',
inject([AppComponent], (app: AppComponent) => {
expect(app).toBeTruthy();
}));
it('should create the app', async(() => {
let fixture = TestBed.createComponent(AppComponent);
let app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));

it('should have as title \'app works!\'',
inject([AppComponent], (app: AppComponent) => {
expect(app.title).toEqual('app works!');
}));
it(`should have as title 'app works!'`, async(() => {
let fixture = TestBed.createComponent(AppComponent);
let app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('app works!');
}));

it('should render title in a h1 tag', async(() => {
let fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
let compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('app works!');
}));
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* tslint:disable:no-unused-variable */

import { addProviders, async, inject } from '@angular/core/testing';
import { TestBed, async } from '@angular/core/testing';
import { <%= classifiedModuleName %>Pipe } from './<%= dasherizedModuleName %>.pipe';

describe('Pipe: <%= classifiedModuleName %>', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/* tslint:disable:no-unused-variable */

import { addProviders, async, inject } from '@angular/core/testing';
import { TestBed, async, inject } from '@angular/core/testing';
import { <%= classifiedModuleName %>Service } from './<%= dasherizedModuleName %>.service';

describe('Service: <%= classifiedModuleName %>', () => {
beforeEach(() => {
addProviders([<%= classifiedModuleName %>Service]);
TestBed.configureTestingModule({
providers: [<%= classifiedModuleName %>Service]
});
});

it('should ...',
inject([<%= classifiedModuleName %>Service],
(service: <%= classifiedModuleName %>Service) => {
expect(service).toBeTruthy();
}));
it('should ...', inject([<%= classifiedModuleName %>Service], (service: <%= classifiedModuleName %>Service) => {
expect(service).toBeTruthy();
}));
});

0 comments on commit 48a695e

Please sign in to comment.