You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
scrutiny/webapp/frontend/src/app/shared/file-size.pipe.spec.ts

36 lines
1.0 KiB

import { FileSizePipe } from './file-size.pipe';
describe('FileSizePipe', () => {
it('create an instance', () => {
const pipe = new FileSizePipe();
expect(pipe).toBeTruthy();
});
describe('#transform',() => {
const testCases = [
{
'bytes': 1500,
'precision': undefined,
'result': '1 KB'
},{
'bytes': 2_100_000_000,
'precision': undefined,
'result': '2.0 GB',
},{
'bytes': 1500,
'precision': 2,
'result': '1.46 KB',
}
]
testCases.forEach((test, index) => {
it(`should correctly format bytes ${test.bytes}. (testcase: ${index + 1})`, () => {
// test
const pipe = new FileSizePipe();
const formatted = pipe.transform(test.bytes, test.precision)
expect(formatted).toEqual(test.result);
});
})
})
});