Below is an example of how I test a pipe that transforms bytes into presentable strings, if that helps.
import { FormatBytesPipe } from '@jfs/shared/pipes/format-bytes.pipe';
describe('Pipe: Format Bytes', () => {
let pipe: FormatBytesPipe;
beforeEach(() => {
pipe = new FormatBytesPipe();
});
it('should transform 0 to "0 Bytes"', () => {
expect(pipe.transform(0)).toEqual('0 Bytes');
});
it('should transform 1024 to "1 KB"', () => {
expect(pipe.transform(Math.pow(1024, 1))).toEqual('1 KB');
});
it('should transform 1024^2 to "1 MB"', () => {
expect(pipe.transform(Math.pow(1024, 2))).toEqual('1 MB');
});
it('should transform 1024^3 to "1 GB"', () => {
expect(pipe.transform(Math.pow(1024, 3))).toEqual('1 GB');
});
it('should transform 1024^4 to "1 TB"', () => {
expect(pipe.transform(Math.pow(1024, 4))).toEqual('1 TB');
});
it('should transform 1024^5 to "1 PB"', () => {
expect(pipe.transform(Math.pow(1024, 5))).toEqual('1 PB');
});
it('should transform 1024^6 to "1 EB"', () => {
expect(pipe.transform(Math.pow(1024, 6))).toEqual('1 EB');
});
it('should transform 1024^7 to "1 ZB"', () => {
expect(pipe.transform(Math.pow(1024, 7))).toEqual('1 ZB');
});
it('should transform 1024^8 to "1 YB"', () => {
expect(pipe.transform(Math.pow(1024, 8))).toEqual('1 YB');
});
});