mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
fix(common): titlecase pipe incorrectly handling numbers (#43476)
Fixes that the `titlecase` pipe wasn't picking up numbers which meant that cases like `1st` would be tranformed to `1St`. Fixes #43459. PR Close #43476
This commit is contained in:
committed by
Jessica Janiuk
parent
c5d0bd4966
commit
df792ebc26
@@ -90,9 +90,16 @@ import {LowerCasePipe, TitleCasePipe, UpperCasePipe} from '@angular/common';
|
||||
expect(pipe.transform('éric')).toEqual('Éric');
|
||||
});
|
||||
|
||||
it('should handle numbers at the beginning of words', () => {
|
||||
expect(pipe.transform('frodo was 1st and bilbo was 2nd'))
|
||||
.toEqual('Frodo Was 1st And Bilbo Was 2nd');
|
||||
expect(pipe.transform('1ST')).toEqual('1st');
|
||||
});
|
||||
|
||||
it('should map null to null', () => {
|
||||
expect(pipe.transform(null)).toEqual(null);
|
||||
});
|
||||
|
||||
it('should map undefined to null', () => {
|
||||
expect(pipe.transform(undefined)).toEqual(null);
|
||||
});
|
||||
@@ -100,6 +107,7 @@ import {LowerCasePipe, TitleCasePipe, UpperCasePipe} from '@angular/common';
|
||||
it('should not support numbers', () => {
|
||||
expect(() => pipe.transform(0 as any)).toThrowError();
|
||||
});
|
||||
|
||||
it('should not support other objects', () => {
|
||||
expect(() => pipe.transform({} as any)).toThrowError();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user