Skip to content

Commit

Permalink
chore: update tests and test support for beta.16
Browse files Browse the repository at this point in the history
  • Loading branch information
wardbell committed Apr 27, 2016
1 parent 74af5aa commit 7a268b5
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 45 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@

* added favicon.ico

<a name="0.1.15"></a>
* testing
- updated wallaby.js and karma.conf.js
- updated app.component.spec.ts


<a name="0.1.15"></a>
# 0.1.15 (2016-04-13)
* Add testing support
* npm scripts
Expand Down
39 changes: 17 additions & 22 deletions app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,14 @@ import {
expect, it, iit, xit,
describe, ddescribe, xdescribe,
beforeEach, beforeEachProviders, withProviders,
inject, injectAsync, TestComponentBuilder
async, inject, 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';

interface Done {
(): void;
fail: (err: any) => void;
}

//////// SPECS /////////////

/// Delete this
Expand All @@ -28,33 +23,33 @@ describe('Smoke test', () => {
});

describe('AppComponent with new', function () {
it('should instantiate component', () => {
expect(new AppComponent()).not.toBeNull('Whoopie!');
});
it('should instantiate component', () => {
expect(new AppComponent()).toBeDefined('Whoopie!');
});
});

describe('AppComponent with TCB', function () {

it('should instantiate component',
injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
async(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {

return tcb.createAsync(AppComponent).then(fixture => {
expect(fixture.componentInstance instanceof AppComponent).toBe(true, 'should create AppComponent');
});
}));
tcb.createAsync(AppComponent).then(fixture => {
expect(fixture.componentInstance instanceof AppComponent).toBe(true, 'should create AppComponent');
});
})));

it('should have expected <h1> text',
injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
async(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {

return tcb.createAsync(AppComponent).then(fixture => {
// fixture.detectChanges(); // needed for a binding; we don't have a binding
tcb.createAsync(AppComponent).then(fixture => {
// fixture.detectChanges(); // would need to resolve a binding but we don't have a binding

let h1 = fixture.debugElement.query(el => el.name === 'h1').nativeElement; // it works
let h1 = fixture.debugElement.query(el => el.name === 'h1').nativeElement; // it works

h1 = fixture.debugElement.query(By.css('h1')).nativeElement; // preferred
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"');
});
expect(h1.innerText).toMatch(/angular 2 app/i, '<h1> should say something about "Angular 2 App"');
});

}));
})));
});
45 changes: 27 additions & 18 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = function(config) {

var appBase = 'app/'; // transpiled app JS files
var appAssets = 'base/app/'; // component assets fetched by Angular's compiler
var appAssets ='/base/app/'; // component assets fetched by Angular's compiler

config.set({
basePath: '',
Expand All @@ -20,23 +20,32 @@ module.exports = function(config) {
flags: ['--no-sandbox']
}
},

files: [
// Angular and shim libraries loaded by Karma
{ pattern: 'node_modules/systemjs/dist/system.src.js', included: true, watched: true },
{ pattern: 'node_modules/es6-shim/es6-shim.js', included: true, watched: true },
{ pattern: 'node_modules/angular2/bundles/angular2-polyfills.js', included: true, watched: true },
{ pattern: 'node_modules/rxjs/bundles/Rx.js', included: true, watched: true },
{ pattern: 'node_modules/angular2/bundles/angular2.js', included: true, watched: true },
{ pattern: 'node_modules/angular2/bundles/testing.dev.js', included: true, watched: true },

// External libraries loaded by Karma
{ pattern: 'node_modules/angular2/bundles/http.dev.js', included: true, watched: true },
{ pattern: 'node_modules/angular2/bundles/router.dev.js', included: true, watched: true },
{ pattern: 'node_modules/a2-in-memory-web-api/web-api.js', included: true, watched: true },

// Configures module loader w/ app and specs, then launch karma
{ pattern: 'karma-test-shim.js', included: true, watched: true },
// System.js for module loading
'node_modules/systemjs/dist/system-polyfills.js',
'node_modules/systemjs/dist/system.src.js',

// Polyfills
'node_modules/es6-shim/es6-shim.js',
'node_modules/angular2/bundles/angular2-polyfills.js',

// Zone.js dependencies
// Note - do not include zone.js itself or long-stack-trace-zone.js` here as
// they are included already in angular2-polyfills
'node_modules/zone.js/dist/jasmine-patch.js',
'node_modules/zone.js/dist/async-test.js',
'node_modules/zone.js/dist/fake-async-test.js',

// RxJs
'node_modules/rxjs/bundles/Rx.js',

// Angular 2 itself and the testing library
'node_modules/angular2/bundles/angular2.js',
'node_modules/angular2/bundles/router.dev.js',
'node_modules/angular2/bundles/http.dev.js',
'node_modules/angular2/bundles/testing.dev.js',

'karma-test-shim.js',

// transpiled application & spec code paths loaded via module imports
{pattern: appBase + '**/*.js', included: false, watched: true},
Expand All @@ -47,7 +56,7 @@ module.exports = function(config) {
{pattern: appBase + '**/*.css', included: false, watched: true},

// paths for debugging with source maps in dev tools
{pattern: appBase + '**/*.ts', included: false, watched: true},
{pattern: appBase + '**/*.ts', included: false, watched: false},
{pattern: appBase + '**/*.js.map', included: false, watched: false}
],

Expand Down
18 changes: 14 additions & 4 deletions wallaby.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,22 @@ module.exports = function () {

return {
files: [
{pattern: 'node_modules/es6-shim/es6-shim.js', instrument: false},
// System.js for module loading
{pattern: 'node_modules/systemjs/dist/system-polyfills.js', instrument: false},
{pattern: 'node_modules/systemjs/dist/system.js', instrument: false},
{pattern: 'node_modules/reflect-metadata/Reflect.js', instrument: false},
{pattern: 'node_modules/zone.js/dist/zone.js', instrument: false},
{pattern: 'node_modules/zone.js/dist/long-stack-trace-zone.js', instrument: false},

// Polyfills
{pattern: 'node_modules/es6-shim/es6-shim.js', instrument: false},
{pattern: 'node_modules/angular2/bundles/angular2-polyfills.js', instrument: false},

// Zone.js dependencies
// Note - do not include zone.js itself or long-stack-trace-zone.js` here as
// they are included already in angular2-polyfills
{pattern: 'node_modules/zone.js/dist/jasmine-patch.js', instrument: false},
{pattern: 'node_modules/zone.js/dist/async-test.js', instrument: false},
{pattern: 'node_modules/zone.js/dist/fake-async-test.js', instrument: false},

// Rx.js, Angular 2 itself, and the testing library not here because loaded by systemjs

{pattern: 'app/**/*+(ts|html|css)', load: false},
{pattern: 'app/**/*.spec.ts', ignore: true}
Expand Down

0 comments on commit 7a268b5

Please sign in to comment.