Add tests for DeviceHoursPipe

pull/634/head
Brice Bauer 5 months ago
parent 142fe06df1
commit a5893f0bf9

@ -1,9 +1,54 @@
import { DeviceHoursPipe } from './device-hours.pipe';
import { DeviceHoursPipe } from "./device-hours.pipe";
describe('DeviceHoursPipe', () => {
it('create an instance', () => {
describe("DeviceHoursPipe", () => {
it("create an instance", () => {
const pipe = new DeviceHoursPipe();
expect(pipe).toBeTruthy();
});
describe("#transform", () => {
const testCases = [
{
input: 12345,
configuration: "device_hours",
result: "12345 hours",
},
{
input: 15273,
configuration: "humanize",
result: "1 year, 8 months, 3 weeks, 6 days, 15 hours",
},
{
input: 48,
configuration: null,
result: "2 days",
},
{
input: 168,
configuration: "scrutiny",
result: "1 week",
},
{
input: null,
configuration: "device_hours",
result: "null hours",
},
{
input: null,
configuration: "humanize",
result: "0 seconds",
},
];
testCases.forEach((test, index) => {
it(`should format input ${test.input} with configuration '${
test.configuration
}' (testcase: ${index + 1})`, () => {
// test
const pipe = new DeviceHoursPipe();
const formatted = pipe.transform(test.input, test.configuration);
expect(formatted).toEqual(test.result);
});
});
});
});

Loading…
Cancel
Save