diff options
Diffstat (limited to '')
-rw-r--r-- | src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/truncate.pipe.spec.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/truncate.pipe.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/truncate.pipe.spec.ts new file mode 100644 index 000000000..cc0b2fc70 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/truncate.pipe.spec.ts @@ -0,0 +1,21 @@ +import { TruncatePipe } from './truncate.pipe'; + +describe('TruncatePipe', () => { + const pipe = new TruncatePipe(); + + it('create an instance', () => { + expect(pipe).toBeTruthy(); + }); + + it('should truncate string (1)', () => { + expect(pipe.transform('fsdfdsfs asdasd', 5, '')).toEqual('fsdfd'); + }); + + it('should truncate string (2)', () => { + expect(pipe.transform('fsdfdsfs asdasd', 10, '...')).toEqual('fsdfdsf...'); + }); + + it('should not truncate number', () => { + expect(pipe.transform(2, 6, '...')).toBe(2); + }); +}); |