2016-06-23 12:47:54 -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
|
|
|
|
*/
|
2017-08-16 12:00:03 -04:00
|
|
|
import {CompileReflector, DirectiveResolver, core} from '@angular/compiler';
|
2016-08-10 18:55:18 -04:00
|
|
|
|
2015-12-03 18:49:09 -05:00
|
|
|
/**
|
|
|
|
* An implementation of {@link DirectiveResolver} that allows overriding
|
|
|
|
* various properties of directives.
|
|
|
|
*/
|
2015-09-08 13:14:57 -04:00
|
|
|
export class MockDirectiveResolver extends DirectiveResolver {
|
2017-08-16 12:00:03 -04:00
|
|
|
private _directives = new Map<core.Type, core.Directive>();
|
2015-09-08 13:14:57 -04:00
|
|
|
|
2017-08-16 12:00:03 -04:00
|
|
|
constructor(reflector: CompileReflector) { super(reflector); }
|
2015-09-08 13:14:57 -04:00
|
|
|
|
2017-08-16 12:00:03 -04:00
|
|
|
resolve(type: core.Type): core.Directive;
|
|
|
|
resolve(type: core.Type, throwIfNotFound: true): core.Directive;
|
|
|
|
resolve(type: core.Type, throwIfNotFound: boolean): core.Directive|null;
|
|
|
|
resolve(type: core.Type, throwIfNotFound = true): core.Directive|null {
|
|
|
|
return this._directives.get(type) || super.resolve(type, throwIfNotFound);
|
2015-09-08 13:14:57 -04:00
|
|
|
}
|
|
|
|
|
2016-07-28 09:45:22 -04:00
|
|
|
/**
|
2017-08-16 12:00:03 -04:00
|
|
|
* Overrides the {@link core.Directive} for a directive.
|
2016-07-28 09:45:22 -04:00
|
|
|
*/
|
2017-08-16 12:00:03 -04:00
|
|
|
setDirective(type: core.Type, metadata: core.Directive): void {
|
2016-07-28 09:45:22 -04:00
|
|
|
this._directives.set(type, metadata);
|
2015-09-08 13:14:57 -04:00
|
|
|
}
|
|
|
|
}
|