Commit 5213e619 authored by Ward Bell's avatar Ward Bell

chore: slightly improve app.component.spec.ts

parent 856a3127
......@@ -5,14 +5,14 @@ import {
expect, it, iit, xit,
describe, ddescribe, xdescribe,
beforeEach, beforeEachProviders, withProviders,
inject, injectAsync, fakeAsync, TestComponentBuilder, tick
inject, injectAsync, TestComponentBuilder
} from 'angular2/testing';
import { By } from 'angular2/platform/browser';
import { provide } from 'angular2/core';
import { ViewMetadata } from 'angular2/core';
import { PromiseWrapper } from 'angular2/src/facade/promise';
/////////// Module Preparation ///////////////////////
interface Done {
(): void;
fail: (err: any) => void;
......@@ -20,15 +20,21 @@ interface Done {
//////// SPECS /////////////
/// Delete this: verify can use Angular testing's DOM abstraction to access DOM
/// Delete this
describe('Smoke test', () => {
it('should run a passing test', () => {
expect(true).toEqual(true, 'should pass');
});
});
describe('AppComponent with new', function () {
it('should instantiate component', () => {
expect(new AppComponent()).not.toBeNull('Whoopie!');
});
});
describe('AppComponent with TCB', function () {
describe('AppComponent', function () {
it('should instantiate component',
injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
......@@ -41,9 +47,14 @@ describe('AppComponent', function () {
injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
return tcb.createAsync(AppComponent).then(fixture => {
// fixture.detectChanges(); // need for a binding; we don't have one
let h1 = fixture.debugElement.query(el => el.name === 'h1').nativeElement;
// fixture.detectChanges(); // needed for a binding; we don't have a binding
let h1 = fixture.debugElement.query(el => el.name === 'h1').nativeElement; // it works
h1 = fixture.debugElement.query(By.css('h1')).nativeElement; // preferred
expect(h1.innerText).toMatch(/angular 2 app/i, '<h1> should say something about "Angular 2 App"');
});
}));
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment