-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Angular: RC6: The library has been updated to Angular RC6. Closes #52. Documentation: Updated to close #51. package dependencies: @angular packages and the rxjs package have been removed from dependencies and added to peerDependencies to allow for more flexible consumption of alternative builds and configurations. The consumer is now responsible to ensure that the correct version is used per the minimum requirements in https://github.com/Stabzs/Angular2-Toaster/blob/master/package.json. Closes #50. toast.component: Due to Angular2-RC5 deprecating `ComponentResolver` and Angular2-RC6 removing `ComponentResolver`, dynamic component resolution has been moved to `Compiler.compileComponentAsync`. toast.component: Dynamic body rendering via component has been moved to the `ngAfterViewInit` lifecycle hook to ensure full module compilation is complete and metadata is attached before attempting to render the component. toast.component: RC6 requires that all dynamically rendered components be enclosed in a `NgModule`. If a module is not used, an error will be thrown at runtime.
- Loading branch information
Showing
9 changed files
with
280 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,95 +1,54 @@ | ||
//Based on https://github.com/mgechev/angular2-seed/blob/master/test-main.js | ||
//Updated with excellent insight from https://github.com/antonybudianto/angular2-starter | ||
|
||
// Turn on full stack traces in errors to help debugging | ||
/*global jasmine, __karma__, window*/ | ||
Error.stackTraceLimit = Infinity; | ||
|
||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000; | ||
|
||
// Cancel Karma's synchronous start, | ||
// we will call `__karma__.start()` later, once all the specs are loaded. | ||
__karma__.loaded = function () { }; | ||
|
||
var paths = { | ||
'n:*': 'node_modules/*' | ||
}; | ||
|
||
// map tells the System loader where to look for things | ||
var map = { | ||
'lib': 'lib', | ||
'src': 'src', | ||
'rxjs': 'n:rxjs', | ||
'@angular': 'n:@angular' | ||
__karma__.loaded = function () { | ||
}; | ||
|
||
var packages = { | ||
'src': { defaultExtension: 'ts', format: 'register' }, | ||
'lib': { defaultExtension: 'js' }, | ||
'rxjs': { defaultExtension: 'js' } | ||
}; | ||
|
||
var packageNames = [ | ||
'@angular/common', | ||
'@angular/compiler', | ||
'@angular/core', | ||
'@angular/platform-browser', | ||
'@angular/platform-browser-dynamic', | ||
'@angular/testing', | ||
]; | ||
|
||
// add package entries for angular packages in the form '@angular/common': { main: 'index.js', defaultExtension: 'js' } | ||
packageNames.forEach(function (pkgName) { | ||
packages[pkgName] = { main: 'index.js', defaultExtension: 'js' }; | ||
}); | ||
|
||
var config = { | ||
baseURL: '/base/', | ||
map: map, | ||
packages: packages, | ||
paths: paths | ||
}; | ||
|
||
System.config(config); | ||
|
||
|
||
Promise.all([ | ||
System.import('@angular/platform-browser/src/browser/browser_adapter'), | ||
System.import('@angular/platform-browser-dynamic/testing'), | ||
System.import('@angular/core/testing'), | ||
]).then(function (modules) { | ||
var browser_adapter = modules[0]; | ||
var providers = modules[1]; | ||
var testing = modules[2]; | ||
testing.setBaseTestProviders(providers.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, | ||
providers.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS); | ||
|
||
browser_adapter.BrowserDomAdapter.makeCurrent(); | ||
}).then(function () { | ||
return Promise.all( | ||
Object.keys(window.__karma__.files) | ||
.filter(onlySpecFiles) | ||
.map(file2moduleName) | ||
.map(importModules) | ||
); | ||
}) | ||
.then(function () { | ||
__karma__.start(); | ||
}, function (error) { | ||
console.error(error.stack || error); | ||
__karma__.start(); | ||
}); | ||
function isJsFile(path) { | ||
return path.slice(-3) == '.js'; | ||
} | ||
|
||
function onlySpecFiles(path) { | ||
return /[\.|-]spec\.js$/.test(path); | ||
function isSpecFile(path) { | ||
return /\.spec\.js$/.test(path); | ||
} | ||
|
||
// Normalize paths to module names. | ||
function file2moduleName(filePath) { | ||
return filePath.replace(/\\/g, '/') | ||
.replace(/^\/base\//, '') | ||
.replace(/\.js/, ''); | ||
function isBuiltFile(path) { | ||
var builtPath = '/base/lib/'; | ||
return isJsFile(path) && (path.substr(0, builtPath.length) == builtPath); | ||
} | ||
|
||
function importModules(path) { | ||
return System.import(path); | ||
} | ||
var allSpecFiles = Object.keys(window.__karma__.files) | ||
.filter(isSpecFile) | ||
.filter(isBuiltFile); | ||
|
||
System.config({ | ||
baseURL: '/base', | ||
packageWithIndex: true | ||
}); | ||
|
||
System.import('systemjs.config.js') | ||
.then(() => Promise.all([ | ||
System.import('@angular/core/testing'), | ||
System.import('@angular/platform-browser-dynamic/testing') | ||
])) | ||
.then((providers) => { | ||
var coreTesting = providers[0]; | ||
var browserTesting = providers[1]; | ||
coreTesting.TestBed.initTestEnvironment( | ||
browserTesting.BrowserDynamicTestingModule, | ||
browserTesting.platformBrowserDynamicTesting()); | ||
|
||
}) | ||
.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(__karma__.start, function (error) { | ||
console.error(error.stack || error); | ||
__karma__.start(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.