2016-07-28 09:40:50 -04:00
|
|
|
/**
|
|
|
|
* @license
|
2020-05-19 15:08:49 -04:00
|
|
|
* Copyright Google LLC All Rights Reserved.
|
2016-07-28 09:40:50 -04:00
|
|
|
*
|
|
|
|
* 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-05-18 16:46:51 -04:00
|
|
|
import {inject} from '@angular/core/testing';
|
2017-08-16 12:00:03 -04:00
|
|
|
import {JitReflector} from '@angular/platform-browser-dynamic/src/compiler_reflector';
|
2017-05-18 16:46:51 -04:00
|
|
|
|
2017-03-02 15:12:46 -05:00
|
|
|
import {MockPipeResolver} from '../testing';
|
2016-07-28 09:40:50 -04:00
|
|
|
|
2017-12-16 17:42:55 -05:00
|
|
|
{
|
2016-07-28 09:40:50 -04:00
|
|
|
describe('MockPipeResolver', () => {
|
2016-11-12 08:08:58 -05:00
|
|
|
let pipeResolver: MockPipeResolver;
|
2016-07-28 09:40:50 -04:00
|
|
|
|
2017-05-18 16:46:51 -04:00
|
|
|
beforeEach(inject([Injector], (injector: Injector) => {
|
2017-08-16 12:00:03 -04:00
|
|
|
pipeResolver = new MockPipeResolver(new JitReflector());
|
2017-05-18 16:46:51 -04:00
|
|
|
}));
|
2016-07-28 09:40:50 -04:00
|
|
|
|
|
|
|
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 {
|
|
|
|
}
|