deno.land / std@0.166.0 / fmt / duration_test.ts

duration_test.ts
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.import { assertEquals, assertExists } from "../testing/asserts.ts";import { format } from "./duration.ts";
Deno.test({ name: "format duration since epoch", fn() { assertExists(format(Date.now())); },});
Deno.test({ name: "format narrow duration", fn() { assertEquals(format(99674), "0d 0h 1m 39s 674ms 0µs 0ns"); },});
Deno.test({ name: "format full duration", fn() { assertEquals( format(99674, { style: "full" }), "0 days, 0 hours, 1 minutes, 39 seconds, 674 milliseconds, 0 microseconds, 0 nanoseconds", ); },});
Deno.test({ name: "format digital duration", fn() { assertEquals( format(99674, { style: "digital" }), "00:00:01:39:674:000:000", ); },});
Deno.test({ name: "format negative duration", fn() { assertEquals( format(-99674, { style: "digital" }), "00:00:01:39:674:000:000", ); },});
Deno.test({ name: "format full duration ignore zero", fn() { assertEquals( format(99674, { style: "full", ignoreZero: true }), "1 minutes, 39 seconds, 674 milliseconds", ); },});
Deno.test({ name: "format narrow duration ignore zero", fn() { assertEquals(format(99674, { ignoreZero: true }), "1m 39s 674ms"); },});
std
Deno standard library
GitHub Repositorydenoland/deno_std
GitHub Stars
2458

Version Info

Tagged at
2 months ago