mirror of
https://github.com/denoland/deno.git
synced 2024-12-28 18:19:08 -05:00
datetime: use assertThrows in test (denoland/deno_std#473)
Original: 3041edb152
This commit is contained in:
parent
21684c679b
commit
33b6055f5f
1 changed files with 17 additions and 15 deletions
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { test } from "../testing/mod.ts";
|
||||
import { assert, assertEquals } from "../testing/asserts.ts";
|
||||
import { assertEquals, assertThrows } from "../testing/asserts.ts";
|
||||
import * as datetime from "./mod.ts";
|
||||
|
||||
test(function parseDateTime(): void {
|
||||
|
@ -31,13 +31,14 @@ test(function parseDateTime(): void {
|
|||
});
|
||||
|
||||
test(function invalidParseDateTimeFormatThrows(): void {
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(datetime as any).parseDateTime("2019-01-01 00:00", "x-y-z");
|
||||
assert(false, "no exception was thrown");
|
||||
} catch (e) {
|
||||
assertEquals(e.message, "Invalid datetime format!");
|
||||
}
|
||||
assertThrows(
|
||||
(): void => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(datetime as any).parseDateTime("2019-01-01 00:00", "x-y-z");
|
||||
},
|
||||
Error,
|
||||
"Invalid datetime format!"
|
||||
);
|
||||
});
|
||||
|
||||
test(function parseDate(): void {
|
||||
|
@ -56,13 +57,14 @@ test(function parseDate(): void {
|
|||
});
|
||||
|
||||
test(function invalidParseDateFormatThrows(): void {
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(datetime as any).parseDate("2019-01-01", "x-y-z");
|
||||
assert(false, "no exception was thrown");
|
||||
} catch (e) {
|
||||
assertEquals(e.message, "Invalid date format!");
|
||||
}
|
||||
assertThrows(
|
||||
(): void => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(datetime as any).parseDate("2019-01-01", "x-y-z");
|
||||
},
|
||||
Error,
|
||||
"Invalid date format!"
|
||||
);
|
||||
});
|
||||
|
||||
test(function DayOfYear(): void {
|
||||
|
|
Loading…
Reference in a new issue