angular-cn/packages/compiler/testing/src/directive_resolver_mock.ts
Joey Perrott d1ea1f4c7f build: update license headers to reference Google LLC (#37205)
Update the license headers throughout the repository to reference Google LLC
rather than Google Inc, for the required license headers.

PR Close #37205
2020-05-26 14:26:58 -04:00

35 lines
1.1 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 {CompileReflector, core, DirectiveResolver} from '@angular/compiler';
/**
* An implementation of {@link DirectiveResolver} that allows overriding
* various properties of directives.
*/
export class MockDirectiveResolver extends DirectiveResolver {
private _directives = new Map<core.Type, core.Directive>();
constructor(reflector: CompileReflector) {
super(reflector);
}
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);
}
/**
* Overrides the {@link core.Directive} for a directive.
*/
setDirective(type: core.Type, metadata: core.Directive): void {
this._directives.set(type, metadata);
}
}