2016-07-28 09:40:50 -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-09-12 22:14:17 -04:00
|
|
|
import {Injector, Pipe} from '@angular/core';
|
2017-03-02 15:12:46 -05:00
|
|
|
import {beforeEach, describe, expect, inject, it} from '@angular/core/testing/src/testing_internal';
|
|
|
|
import {MockPipeResolver} from '../testing';
|
2016-07-28 09:40:50 -04:00
|
|
|
|
|
|
|
export function main() {
|
|
|
|
describe('MockPipeResolver', () => {
|
2016-11-12 08:08:58 -05:00
|
|
|
let pipeResolver: MockPipeResolver;
|
2016-07-28 09:40:50 -04:00
|
|
|
|
|
|
|
beforeEach(inject(
|
|
|
|
[Injector], (injector: Injector) => { pipeResolver = new MockPipeResolver(injector); }));
|
|
|
|
|
|
|
|
describe('Pipe overriding', () => {
|
|
|
|
it('should fallback to the default PipeResolver when templates are not overridden', () => {
|
2016-11-12 08:08:58 -05:00
|
|
|
const pipe = pipeResolver.resolve(SomePipe);
|
2016-07-28 09:40:50 -04:00
|
|
|
expect(pipe.name).toEqual('somePipe');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should allow overriding the @Pipe', () => {
|
2016-09-12 22:14:17 -04:00
|
|
|
pipeResolver.setPipe(SomePipe, new Pipe({name: 'someOtherName'}));
|
2016-11-12 08:08:58 -05:00
|
|
|
const pipe = pipeResolver.resolve(SomePipe);
|
2016-07-28 09:40:50 -04:00
|
|
|
expect(pipe.name).toEqual('someOtherName');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@Pipe({name: 'somePipe'})
|
|
|
|
class SomePipe {
|
|
|
|
}
|