46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright Google LLC 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
|
|
*/
|
|
|
|
import {NgModule} from '@angular/core';
|
|
import {JitReflector} from '@angular/platform-browser-dynamic/src/compiler_reflector';
|
|
|
|
import {MockNgModuleResolver} from '../testing';
|
|
|
|
{
|
|
describe('MockNgModuleResolver', () => {
|
|
let ngModuleResolver: MockNgModuleResolver;
|
|
|
|
beforeEach(() => {
|
|
ngModuleResolver = new MockNgModuleResolver(new JitReflector());
|
|
});
|
|
|
|
describe('NgModule overriding', () => {
|
|
it('should fallback to the default NgModuleResolver when templates are not overridden',
|
|
() => {
|
|
const ngModule = ngModuleResolver.resolve(SomeNgModule);
|
|
expect(ngModule.declarations).toEqual([SomeDirective]);
|
|
});
|
|
|
|
it('should allow overriding the @NgModule', () => {
|
|
ngModuleResolver.setNgModule(
|
|
SomeNgModule, new NgModule({declarations: [SomeOtherDirective]}));
|
|
const ngModule = ngModuleResolver.resolve(SomeNgModule);
|
|
expect(ngModule.declarations).toEqual([SomeOtherDirective]);
|
|
});
|
|
});
|
|
});
|
|
}
|
|
|
|
class SomeDirective {}
|
|
|
|
class SomeOtherDirective {}
|
|
|
|
@NgModule({declarations: [SomeDirective]})
|
|
class SomeNgModule {
|
|
}
|