Page MenuHomeSealhub

time-units.test.ts
No OneTemporary

time-units.test.ts

import time_units, { TimeUnit } from "./time-units";
import * as assert from "assert";
const formats: { [full_name: string]: [TimeUnit, number] } = {
hours: ["h", 3600000],
minutes: ["m", 60000],
seconds: ["s", 1000],
miliseconds: ["ms", 1],
};
describe("time-units-function", () => {
describe("convertion", () => {
Object.keys(formats).forEach((format: keyof typeof formats) => {
it(`should convert ${format} to hours`, () => {
const result = time_units(formats[format][0], "h", 1);
assert.equal(
result,
(formats[format][1] / 3600000).toPrecision(8)
);
});
it(`should convert ${format} to minutes`, () => {
const result = time_units(formats[format][0], "m", 1);
assert.equal(
result,
(formats[format][1] / 60000).toPrecision(8)
);
});
it(`should convert ${format} to seconds`, () => {
const result = time_units(formats[format][0], "s", 1);
assert.equal(
result,
(formats[format][1] / 1000).toPrecision(8)
);
});
it(`should convert ${format} to miliseconds`, () => {
const result = time_units(formats[format][0], "ms", 1);
assert.equal(result, (formats[format][1] / 1).toPrecision(8));
});
});
});
});

File Metadata

Mime Type
text/x-java
Expires
Mon, Dec 23, 10:42 (1 d, 6 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
555873
Default Alt Text
time-units.test.ts (1 KB)

Event Timeline