Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(fmt): add invalid duration style option test #6310

Merged
merged 3 commits into from
Jan 4, 2025
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion fmt/duration_test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { assertEquals, assertExists } from "@std/assert";
import { assertEquals, assertExists, assertThrows } from "@std/assert";
import { format } from "./duration.ts";
import type { FormatOptions } from "./duration.ts";

Deno.test({
name: "format() handles duration since epoch",
Expand Down Expand Up @@ -90,3 +91,15 @@ Deno.test({
assertEquals(format(16.342, { ignoreZero: true }), "16ms 342µs");
},
});

Deno.test({
name: "format() throws on invalid style option",
fn() {
assertThrows(
() =>
format(16.342, { style: "invalid" as keyof FormatOptions["style"] }),
TypeError,
'style must be "narrow", "full", or "digital"!',
);
},
});
Loading