fix(common): titlecase pipe (#22600)

PR Close #22600
This commit is contained in:
sergeome
2018-03-13 21:46:10 -05:00
committed by Matias Niemelä
parent d9a0a8ff3e
commit 7966744a44
5 changed files with 92 additions and 17 deletions

File diff suppressed because one or more lines are too long

View File

@ -45,6 +45,27 @@ import {LowerCasePipe, TitleCasePipe, UpperCasePipe} from '@angular/common';
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 treat non-space character as a separator', () => {
expect(pipe.transform('one,two,three')).toEqual('One,two,three');
expect(pipe.transform('true|false')).toEqual('True|false');
expect(pipe.transform('foo-vs-bar')).toEqual('Foo-vs-bar');
});
it('should support support all whitespace characters', () => {
expect(pipe.transform('one\ttwo')).toEqual('One\tTwo');
expect(pipe.transform('three\rfour')).toEqual('Three\rFour');
expect(pipe.transform('five\nsix')).toEqual('Five\nSix');
});
it('should work properly for non-latin alphabet', () => {
expect(pipe.transform('føderation')).toEqual('Føderation');
expect(pipe.transform('poniedziałek')).toEqual('Poniedziałek');
expect(pipe.transform('éric')).toEqual('Éric');
});
it('should not support other objects',
() => { expect(() => pipe.transform(<any>{})).toThrowError(); });
});