@ -12,41 +12,55 @@ import {LowerCasePipe, TitleCasePipe, UpperCasePipe} from '@angular/common';
|
||||
describe('LowerCasePipe', () => {
|
||||
let pipe: LowerCasePipe;
|
||||
|
||||
beforeEach(() => { pipe = new LowerCasePipe(); });
|
||||
beforeEach(() => {
|
||||
pipe = new LowerCasePipe();
|
||||
});
|
||||
|
||||
it('should return lowercase', () => { expect(pipe.transform('FOO')).toEqual('foo'); });
|
||||
it('should return lowercase', () => {
|
||||
expect(pipe.transform('FOO')).toEqual('foo');
|
||||
});
|
||||
|
||||
it('should lowercase when there is a new value', () => {
|
||||
expect(pipe.transform('FOO')).toEqual('foo');
|
||||
expect(pipe.transform('BAr')).toEqual('bar');
|
||||
});
|
||||
|
||||
it('should not support other objects',
|
||||
() => { expect(() => pipe.transform(<any>{})).toThrowError(); });
|
||||
it('should not support other objects', () => {
|
||||
expect(() => pipe.transform(<any>{})).toThrowError();
|
||||
});
|
||||
});
|
||||
|
||||
describe('TitleCasePipe', () => {
|
||||
let pipe: TitleCasePipe;
|
||||
|
||||
beforeEach(() => { pipe = new TitleCasePipe(); });
|
||||
beforeEach(() => {
|
||||
pipe = new TitleCasePipe();
|
||||
});
|
||||
|
||||
it('should return titlecase', () => { expect(pipe.transform('foo')).toEqual('Foo'); });
|
||||
it('should return titlecase', () => {
|
||||
expect(pipe.transform('foo')).toEqual('Foo');
|
||||
});
|
||||
|
||||
it('should return titlecase for subsequent words',
|
||||
() => { expect(pipe.transform('one TWO Three fouR')).toEqual('One Two Three Four'); });
|
||||
it('should return titlecase for subsequent words', () => {
|
||||
expect(pipe.transform('one TWO Three fouR')).toEqual('One Two Three Four');
|
||||
});
|
||||
|
||||
it('should support empty strings', () => { expect(pipe.transform('')).toEqual(''); });
|
||||
it('should support empty strings', () => {
|
||||
expect(pipe.transform('')).toEqual('');
|
||||
});
|
||||
|
||||
it('should persist whitespace',
|
||||
() => { expect(pipe.transform('one two')).toEqual('One Two'); });
|
||||
it('should persist whitespace', () => {
|
||||
expect(pipe.transform('one two')).toEqual('One Two');
|
||||
});
|
||||
|
||||
it('should titlecase when there is a new value', () => {
|
||||
expect(pipe.transform('bar')).toEqual('Bar');
|
||||
expect(pipe.transform('foo')).toEqual('Foo');
|
||||
});
|
||||
|
||||
it('should not capitalize letter after the quotes',
|
||||
() => { expect(pipe.transform('it\'s complicated')).toEqual('It\'s Complicated'); });
|
||||
it('should not capitalize letter after the quotes', () => {
|
||||
expect(pipe.transform('it\'s complicated')).toEqual('It\'s Complicated');
|
||||
});
|
||||
|
||||
it('should not treat non-space character as a separator', () => {
|
||||
expect(pipe.transform('one,two,three')).toEqual('One,two,three');
|
||||
@ -66,23 +80,29 @@ import {LowerCasePipe, TitleCasePipe, UpperCasePipe} from '@angular/common';
|
||||
expect(pipe.transform('éric')).toEqual('Éric');
|
||||
});
|
||||
|
||||
it('should not support other objects',
|
||||
() => { expect(() => pipe.transform(<any>{})).toThrowError(); });
|
||||
it('should not support other objects', () => {
|
||||
expect(() => pipe.transform(<any>{})).toThrowError();
|
||||
});
|
||||
});
|
||||
|
||||
describe('UpperCasePipe', () => {
|
||||
let pipe: UpperCasePipe;
|
||||
|
||||
beforeEach(() => { pipe = new UpperCasePipe(); });
|
||||
beforeEach(() => {
|
||||
pipe = new UpperCasePipe();
|
||||
});
|
||||
|
||||
it('should return uppercase', () => { expect(pipe.transform('foo')).toEqual('FOO'); });
|
||||
it('should return uppercase', () => {
|
||||
expect(pipe.transform('foo')).toEqual('FOO');
|
||||
});
|
||||
|
||||
it('should uppercase when there is a new value', () => {
|
||||
expect(pipe.transform('foo')).toEqual('FOO');
|
||||
expect(pipe.transform('bar')).toEqual('BAR');
|
||||
});
|
||||
|
||||
it('should not support other objects',
|
||||
() => { expect(() => pipe.transform(<any>{})).toThrowError(); });
|
||||
it('should not support other objects', () => {
|
||||
expect(() => pipe.transform(<any>{})).toThrowError();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user