
BREAKING CHANGE: - Renderer: * renderComponent method is removed form `Renderer`, only present on `RootRenderer` * Renderer.setDebugInfo is removed. Renderer.createElement / createText / createTemplateAnchor now take the DebugInfo directly. - Query semantics: * Queries don't work with dynamically loaded components. * e.g. for router-outlet: loaded components can't be queries via @ViewQuery, but router-outlet emits an event `activate` now that emits the activated component - Exception classes and the context inside changed (renamed fields) - DebugElement.attributes is an Object and not a Map in JS any more - ChangeDetectorGenConfig was renamed into CompilerConfig - AppViewManager.createEmbeddedViewInContainer / AppViewManager.createHostViewInContainer are removed, use the methods in ViewContainerRef instead - Change detection order changed: * 1. dirty check component inputs * 2. dirty check content children * 3. update render nodes Closes #6301 Closes #6567
53 lines
1.5 KiB
TypeScript
53 lines
1.5 KiB
TypeScript
import {
|
|
ddescribe,
|
|
describe,
|
|
it,
|
|
iit,
|
|
xit,
|
|
expect,
|
|
beforeEach,
|
|
afterEach
|
|
} from 'angular2/testing_internal';
|
|
|
|
import {I18nSelectPipe} from 'angular2/common';
|
|
import {PipeResolver} from 'angular2/src/compiler/pipe_resolver';
|
|
|
|
export function main() {
|
|
describe("I18nSelectPipe", () => {
|
|
var pipe;
|
|
var mapping = {'male': 'Invite him.', 'female': 'Invite her.', 'other': 'Invite them.'};
|
|
|
|
beforeEach(() => { pipe = new I18nSelectPipe(); });
|
|
|
|
it('should be marked as pure',
|
|
() => { expect(new PipeResolver().resolve(I18nSelectPipe).pure).toEqual(true); });
|
|
|
|
describe("transform", () => {
|
|
it("should return male text if value is male", () => {
|
|
var val = pipe.transform('male', [mapping]);
|
|
expect(val).toEqual('Invite him.');
|
|
});
|
|
|
|
it("should return female text if value is female", () => {
|
|
var val = pipe.transform('female', [mapping]);
|
|
expect(val).toEqual('Invite her.');
|
|
});
|
|
|
|
it("should return other text if value is anything other than male or female", () => {
|
|
var val = pipe.transform('Anything else', [mapping]);
|
|
expect(val).toEqual('Invite them.');
|
|
});
|
|
|
|
it("should use 'other' if value is undefined", () => {
|
|
var gender;
|
|
var val = pipe.transform(gender, [mapping]);
|
|
expect(val).toEqual('Invite them.');
|
|
});
|
|
|
|
it("should not support bad arguments",
|
|
() => { expect(() => pipe.transform('male', ['hey'])).toThrowError(); });
|
|
});
|
|
|
|
});
|
|
}
|