feat: update to @angular rc0 packages & latest CLI (#384)

- Includes update to newest router
- Completely rewrites checkbox tests
This commit is contained in:
Jeremy Elbourn
2016-05-03 22:38:22 -07:00
parent 6e4fe5e417
commit 04c8a1f830
69 changed files with 986 additions and 1265 deletions
+47 -81
View File
@@ -1,91 +1,57 @@
/*global jasmine, __karma__, window*/
Error.stackTraceLimit = Infinity;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 4000;
__karma__.loaded = function () {
};
__karma__.loaded = function() {};
var distPath = '/base/dist/';
/**
* Gets map of module alias to location or package.
* @param dir Directory name under `src/` for create a map for.
*/
function getPathsMap(dir) {
return Object.keys(window.__karma__.files)
.filter(not(isSpecFile))
.filter(function(x) { return new RegExp('^/base/dist/' + dir + '/.*\\.js$').test(x); })
.reduce(function(pathsMapping, appPath) {
var pathToReplace = new RegExp('^/base/dist/' + dir + '/');
var moduleName = appPath.replace(pathToReplace, './').replace(/\.js$/, '');
pathsMapping[moduleName] = appPath + '?' + window.__karma__.files[appPath];
return pathsMapping;
}, {});
function isJsFile(path) {
return path.slice(-3) == '.js';
}
System.config({
packages: {
'base/dist/components': {
defaultExtension: false,
format: 'cjs',
map: getPathsMap('components')
},
'base/dist/core': {
defaultExtension: false,
format: 'cjs',
map: getPathsMap('core')
},
}
});
/**
* Bootstrap the browser testing providers from Angular2. The equivalent code in TypeScript
* would be:
*
* <code>
* import {setBaseTestProviders} from 'angular2/testing';
* import * as browser from 'angular2/platform/testing/browser';
*
* setBaseTestProviders(browser.TEST_BROWSER_PLATFORM_PROVIDERS,
* browser.TEST_BROWSER_APPLICATION_PROVIDERS);
* </code>
*
* See https://github.com/angular/angular/blob/master/CHANGELOG.md#200-beta2-2016-01-28
*
* Followed by the normal import of all spec files, then bootstrap Karma.
*/
Promise.all([
System.import('angular2/testing'),
System.import('angular2/platform/testing/browser'),
]).then(function(imports) {
var testing = imports[0];
var browser = imports[1];
testing.setBaseTestProviders(browser.TEST_BROWSER_PLATFORM_PROVIDERS,
browser.TEST_BROWSER_APPLICATION_PROVIDERS);
return Promise.all(
Object.keys(window.__karma__.files)
.filter(isSpecFile)
.map(function(moduleName) {
return System.import(moduleName).then(function(module) {
if (module.hasOwnProperty('main')) {
return module.main();
} else {
return module;
}
});
}));
}).then(function() {
__karma__.start();
}, function(error) {
__karma__.error(error.stack || error);
});
function isSpecFile(path) {
return /\.spec\.js$/.test(path);
return path.slice(-8) == '.spec.js';
}
function not(fn) {
return function() {
return !fn.apply(this, arguments);
};
function isMaterialFile(path) {
return isJsFile(path) && path.indexOf('vendor') == -1;
}
var allSpecFiles = Object.keys(window.__karma__.files)
.filter(isSpecFile)
.filter(isMaterialFile);
// Load our SystemJS configuration.
System.config({
baseURL: distPath
});
System.import('system-config.js').then(function() {
// Load and configure the TestComponentBuilder.
return Promise.all([
System.import('@angular/core/testing'),
System.import('@angular/platform-browser-dynamic/testing')
]).then(function (providers) {
var testing = providers[0];
var testingBrowser = providers[1];
testing.setBaseTestProviders(testingBrowser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
testingBrowser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);
});
}).then(function() {
// Finally, load all spec files.
// This will run the tests directly.
return Promise.all(
allSpecFiles.map(function (moduleName) {
return System.import(moduleName).then(function(module) {
// TODO(jelbourn): remove `main` method from tests and this check.
if (module.hasOwnProperty('main')) {
return module.main();
} else {
return module;
}
});
}));
}).then(__karma__.start, __karma__.error);
+7 -18
View File
@@ -19,22 +19,13 @@ export function config(config) {
require('karma-firefox-launcher'),
],
files: [
{pattern: 'node_modules/es6-shim/es6-shim.min.js', included: true, watched: false},
{pattern: 'node_modules/systemjs/dist/system-polyfills.js', included: true, watched: false},
'node_modules/angular2/es6/dev/src/testing/shims_for_IE.js',
// Angular 2 polyfills *must* be loaded after es6-shim and system-polyfills in order to
// setup the monkey-patches for zones.
{pattern: 'node_modules/angular2/bundles/angular2-polyfills.js', included: true, watched: false},
{pattern: 'node_modules/zone.js/dist/jasmine-patch.js', included: true, watched: false},
{pattern: 'node_modules/zone.js/dist/async-test.js', included: true, watched: false},
{pattern: 'node_modules/zone.js/dist/fake-async-test.js', included: true, watched: false},
{pattern: 'node_modules/systemjs/dist/system.src.js', included: true, watched: false},
{pattern: 'node_modules/rxjs/bundles/Rx.js', included: true, watched: false},
'node_modules/reflect-metadata/Reflect.js',
{pattern: 'node_modules/angular2/bundles/angular2.dev.js', included: true, watched: false},
{pattern: 'node_modules/angular2/bundles/http.dev.js', included: true, watched: false},
{pattern: 'node_modules/angular2/bundles/testing.dev.js', included: true, watched: false},
{pattern: 'dist/vendor/es6-shim/es6-shim.js', included: true, watched: false},
{pattern: 'dist/vendor/reflect-metadata/Reflect.js', included: true, watched: false},
{pattern: 'dist/vendor/systemjs/dist/system-polyfills.js', included: true, watched: false},
{pattern: 'dist/vendor/systemjs/dist/system.src.js', included: true, watched: false},
{pattern: 'dist/vendor/zone.js/dist/zone.js', included: true, watched: false},
{pattern: 'dist/vendor/zone.js/dist/async-test.js', included: true, watched: false},
{pattern: 'dist/vendor/zone.js/dist/fake-async-test.js', included: true, watched: false},
{pattern: 'test/karma-test-shim.js', included: true, watched: true},
@@ -52,10 +43,8 @@ export function config(config) {
],
proxies: {
// required for component assests fetched by Angular's compiler
'/demo-app/': '/base/dist/demo-app/',
'/components/': '/base/dist/components/',
'/core/': '/base/dist/core/',
'/directives/': '/base/dist/directives/',
},
customLaunchers: customLaunchers,