2016-07-18 06:50:31 -04:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
2016-08-02 18:53:34 -04:00
|
|
|
import {Injector, NgModule, NgModuleMetadata} from '@angular/core';
|
|
|
|
import {beforeEach, ddescribe, describe, expect, iit, inject, it} from '@angular/core/testing/testing_internal';
|
2016-07-18 06:50:31 -04:00
|
|
|
|
2016-08-02 18:53:34 -04:00
|
|
|
import {isBlank, stringify} from '../src/facade/lang';
|
2016-08-30 21:07:40 -04:00
|
|
|
import {MockNgModuleResolver} from '../testing/index';
|
2016-07-18 06:50:31 -04:00
|
|
|
|
|
|
|
export function main() {
|
|
|
|
describe('MockNgModuleResolver', () => {
|
|
|
|
var ngModuleResolver: MockNgModuleResolver;
|
|
|
|
|
|
|
|
beforeEach(inject([Injector], (injector: Injector) => {
|
|
|
|
ngModuleResolver = new MockNgModuleResolver(injector);
|
|
|
|
}));
|
|
|
|
|
|
|
|
describe('NgModule overriding', () => {
|
|
|
|
it('should fallback to the default NgModuleResolver when templates are not overridden',
|
|
|
|
() => {
|
|
|
|
var ngModule = ngModuleResolver.resolve(SomeNgModule);
|
|
|
|
expect(ngModule.declarations).toEqual([SomeDirective]);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should allow overriding the @NgModule', () => {
|
|
|
|
ngModuleResolver.setNgModule(
|
|
|
|
SomeNgModule, new NgModuleMetadata({declarations: [SomeOtherDirective]}));
|
|
|
|
var ngModule = ngModuleResolver.resolve(SomeNgModule);
|
|
|
|
expect(ngModule.declarations).toEqual([SomeOtherDirective]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
class SomeDirective {}
|
|
|
|
|
|
|
|
class SomeOtherDirective {}
|
|
|
|
|
|
|
|
@NgModule({declarations: [SomeDirective]})
|
|
|
|
class SomeNgModule {
|
|
|
|
}
|