Skip to content

Commit e3dc30a

Browse files
authored
test(fmt): add invalid duration style option test (denoland#6310)
1 parent 89d4ba4 commit e3dc30a

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

fmt/duration_test.ts

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright 2018-2025 the Deno authors. MIT license.
2-
import { assertEquals, assertExists } from "@std/assert";
2+
import { assertEquals, assertExists, assertThrows } from "@std/assert";
33
import { format } from "./duration.ts";
4+
import type { FormatOptions } from "./duration.ts";
45

56
Deno.test({
67
name: "format() handles duration since epoch",
@@ -90,3 +91,15 @@ Deno.test({
9091
assertEquals(format(16.342, { ignoreZero: true }), "16ms 342µs");
9192
},
9293
});
94+
95+
Deno.test({
96+
name: "format() throws on invalid style option",
97+
fn() {
98+
assertThrows(
99+
() =>
100+
format(16.342, { style: "invalid" as keyof FormatOptions["style"] }),
101+
TypeError,
102+
'style must be "narrow", "full", or "digital"!',
103+
);
104+
},
105+
});

0 commit comments

Comments
 (0)