import { TrimToLengthPipe } from './trim-to-length.pipe'; describe('TrimToLengthPipe', () => { it('create an instance', () => { const pipe = new TrimToLengthPipe(); expect(pipe).toBeTruthy(); }); it('handles the empty string', () => { const pipe = new TrimToLengthPipe(); expect(pipe.transform('', 5)).toEqual(''); }); it('handles null', () => { const pipe = new TrimToLengthPipe(); expect(pipe.transform(null, 5)).toEqual(''); }); it('handles undefined', () => { const pipe = new TrimToLengthPipe(); expect(pipe.transform(undefined, 5)).toEqual(''); }); it('does not trim string that is shorter than the desired length', () => { const pipe = new TrimToLengthPipe(); expect(pipe.transform('hi', 5)).toEqual('hi'); }); it('trims a long string to desired length', () => { const pipe = new TrimToLengthPipe(); expect(pipe.transform('It was the best of times, it was the worst of times', 5)).toEqual('It...'); }); });