Commit 7a268b5a authored by Ward Bell's avatar Ward Bell

chore: update tests and test support for beta.16

parent 74af5aab
...@@ -9,7 +9,12 @@ ...@@ -9,7 +9,12 @@
* added favicon.ico * 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) # 0.1.15 (2016-04-13)
* Add testing support * Add testing support
* npm scripts * npm scripts
......
...@@ -5,7 +5,7 @@ import { ...@@ -5,7 +5,7 @@ import {
expect, it, iit, xit, expect, it, iit, xit,
describe, ddescribe, xdescribe, describe, ddescribe, xdescribe,
beforeEach, beforeEachProviders, withProviders, beforeEach, beforeEachProviders, withProviders,
inject, injectAsync, TestComponentBuilder async, inject, TestComponentBuilder
} from 'angular2/testing'; } from 'angular2/testing';
import { By } from 'angular2/platform/browser'; import { By } from 'angular2/platform/browser';
...@@ -13,11 +13,6 @@ import { provide } from 'angular2/core'; ...@@ -13,11 +13,6 @@ import { provide } from 'angular2/core';
import { ViewMetadata } from 'angular2/core'; import { ViewMetadata } from 'angular2/core';
import { PromiseWrapper } from 'angular2/src/facade/promise'; import { PromiseWrapper } from 'angular2/src/facade/promise';
interface Done {
(): void;
fail: (err: any) => void;
}
//////// SPECS ///////////// //////// SPECS /////////////
/// Delete this /// Delete this
...@@ -28,33 +23,33 @@ describe('Smoke test', () => { ...@@ -28,33 +23,33 @@ describe('Smoke test', () => {
}); });
describe('AppComponent with new', function () { describe('AppComponent with new', function () {
it('should instantiate component', () => { it('should instantiate component', () => {
expect(new AppComponent()).not.toBeNull('Whoopie!'); expect(new AppComponent()).toBeDefined('Whoopie!');
}); });
}); });
describe('AppComponent with TCB', function () { describe('AppComponent with TCB', function () {
it('should instantiate component', it('should instantiate component',
injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { async(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
return tcb.createAsync(AppComponent).then(fixture => { tcb.createAsync(AppComponent).then(fixture => {
expect(fixture.componentInstance instanceof AppComponent).toBe(true, 'should create AppComponent'); expect(fixture.componentInstance instanceof AppComponent).toBe(true, 'should create AppComponent');
}); });
})); })));
it('should have expected <h1> text', it('should have expected <h1> text',
injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => { async(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
return tcb.createAsync(AppComponent).then(fixture => { tcb.createAsync(AppComponent).then(fixture => {
// fixture.detectChanges(); // needed for a binding; we don't have a binding // 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"');
}); });
})); })));
}); });
module.exports = function(config) { module.exports = function(config) {
var appBase = 'app/'; // transpiled app JS files 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({ config.set({
basePath: '', basePath: '',
...@@ -20,23 +20,32 @@ module.exports = function(config) { ...@@ -20,23 +20,32 @@ module.exports = function(config) {
flags: ['--no-sandbox'] flags: ['--no-sandbox']
} }
}, },
files: [ files: [
// Angular and shim libraries loaded by Karma // System.js for module loading
{ pattern: 'node_modules/systemjs/dist/system.src.js', included: true, watched: true }, 'node_modules/systemjs/dist/system-polyfills.js',
{ pattern: 'node_modules/es6-shim/es6-shim.js', included: true, watched: true }, 'node_modules/systemjs/dist/system.src.js',
{ pattern: 'node_modules/angular2/bundles/angular2-polyfills.js', included: true, watched: true },
{ pattern: 'node_modules/rxjs/bundles/Rx.js', included: true, watched: true }, // Polyfills
{ pattern: 'node_modules/angular2/bundles/angular2.js', included: true, watched: true }, 'node_modules/es6-shim/es6-shim.js',
{ pattern: 'node_modules/angular2/bundles/testing.dev.js', included: true, watched: true }, 'node_modules/angular2/bundles/angular2-polyfills.js',
// External libraries loaded by Karma // Zone.js dependencies
{ pattern: 'node_modules/angular2/bundles/http.dev.js', included: true, watched: true }, // Note - do not include zone.js itself or long-stack-trace-zone.js` here as
{ pattern: 'node_modules/angular2/bundles/router.dev.js', included: true, watched: true }, // they are included already in angular2-polyfills
{ pattern: 'node_modules/a2-in-memory-web-api/web-api.js', included: true, watched: true }, 'node_modules/zone.js/dist/jasmine-patch.js',
'node_modules/zone.js/dist/async-test.js',
// Configures module loader w/ app and specs, then launch karma 'node_modules/zone.js/dist/fake-async-test.js',
{ pattern: 'karma-test-shim.js', included: true, watched: true },
// 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 // transpiled application & spec code paths loaded via module imports
{pattern: appBase + '**/*.js', included: false, watched: true}, {pattern: appBase + '**/*.js', included: false, watched: true},
...@@ -47,7 +56,7 @@ module.exports = function(config) { ...@@ -47,7 +56,7 @@ module.exports = function(config) {
{pattern: appBase + '**/*.css', included: false, watched: true}, {pattern: appBase + '**/*.css', included: false, watched: true},
// paths for debugging with source maps in dev tools // 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} {pattern: appBase + '**/*.js.map', included: false, watched: false}
], ],
......
...@@ -5,12 +5,22 @@ module.exports = function () { ...@@ -5,12 +5,22 @@ module.exports = function () {
return { return {
files: [ 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/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}, // Polyfills
{pattern: 'node_modules/zone.js/dist/long-stack-trace-zone.js', instrument: false}, {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/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/**/*+(ts|html|css)', load: false},
{pattern: 'app/**/*.spec.ts', ignore: true} {pattern: 'app/**/*.spec.ts', ignore: true}
......
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