| ... | ... | @@ -29,22 +29,37 @@ test("escapeShellArgument", () => { |
| 29 | 29 | assert.equal(string.escapeShellArgument("'string"), "\"'string\""); |
| 30 | 30 | assert.equal(string.escapeShellArgument("'str\"ing"), "\\''str\"ing'"); |
| 31 | 31 | }); |
| 32 | | test.todo("formatByteSize", () => { |
| 32 | test("formatByteSize", () => { |
| 33 | 33 | assert.equal(string.formatByteSize(0), "0B"); |
| 34 | 34 | assert.equal(string.formatByteSize(1), "1B"); |
| 35 | 35 | assert.equal(string.formatByteSize(1000), "1kB"); |
| 36 | 36 | assert.equal(string.formatByteSize(-1000), "-1kB"); |
| 37 | 37 | assert.equal(string.formatByteSize(1500), "1.5kB"); |
| 38 | 38 | assert.equal(string.formatByteSize(1578), "1.58kB"); |
| 39 | | assert.equal(string.formatByteSize(5_100_000), "5.1MB"); |
| 39 | assert.equal(string.formatByteSize(5_100_000), "5.10MB"); |
| 40 | 40 | assert.equal(string.formatByteSize(-7_231_692_881), "-7.23GB"); |
| 41 | | assert.equal(string.formatByteSize(-4_294_967_296), "-7.23GB"); |
| 41 | assert.equal(string.formatByteSize(-4_294_967_296), "-4.29GB"); |
| 42 | 42 | |
| 43 | 43 | assert.equal(string.formatByteSize(53.251), "53.25B"); |
| 44 | 44 | assert.equal(string.formatByteSize(Infinity), "Infinity"); |
| 45 | 45 | assert.equal(string.formatByteSize(-Infinity), "-Infinity"); |
| 46 | 46 | assert.equal(string.formatByteSize(NaN), "NaN"); |
| 47 | 47 | }); |
| 48 | test("formatDurationLetters", () => { |
| 49 | assert.equal(string.formatDurationLetters(1), "1s"); |
| 50 | assert.equal(string.formatDurationLetters(1.542), "1.54s"); |
| 51 | assert.equal(string.formatDurationLetters(1.5), "1.5s"); |
| 52 | assert.equal(string.formatDurationLetters(60), "1m"); |
| 53 | assert.equal(string.formatDurationLetters(65), "1m5s"); |
| 54 | assert.equal(string.formatDurationLetters(10000), "2h46m"); |
| 55 | assert.equal(string.formatDurationLetters(421321378), "13y131d"); |
| 56 | |
| 57 | assert.equal(string.formatDurationLetters(0), "now"); |
| 58 | assert.equal(string.formatDurationLetters(-3000), "50m ago"); |
| 59 | assert.equal(string.formatDurationLetters(Infinity), "forever"); |
| 60 | assert.equal(string.formatDurationLetters(-Infinity), "forever ago"); |
| 61 | assert.equal(string.formatDurationLetters(NaN), "NaN"); |
| 62 | }); |
| 48 | 63 | |
| 49 | 64 | import assert from "node:assert"; |
| 50 | 65 | import { test } from "vitest"; |