-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dev_deps.ts
53 lines (46 loc) · 1.28 KB
/
dev_deps.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
// Copyright 2021-Present the Unitest authors. All rights reserved. MIT license.
// This module is browser compatible.
import { assertThrows } from "https://deno.land/std@0.118.0/testing/asserts.ts";
export {
assert,
assertExists,
assertNotEquals,
assertRejects,
assertThrows,
} from "https://deno.land/std@0.118.0/testing/asserts.ts";
import { AssertionError, blue } from "./deps.ts";
import { assertEquals } from "https://deno.land/std@0.118.0/testing/asserts.ts";
import type { Matcher, MatchResult } from "./matcher/types.ts";
function assertSuccess({ pass }: MatchResult): void {
assertEquals(pass, true);
}
function assertFail({ pass }: MatchResult): void {
assertEquals(pass, false);
}
function assertExpected(
{ matcher, expected }: {
matcher: Matcher;
expected: MatchResult["expected"];
},
options: Partial<{
actual: unknown;
expectedArgs: readonly unknown[];
}> = { actual: {}, expectedArgs: [] },
): void {
assertEquals(
matcher(options.actual, ...options.expectedArgs ?? []).expected,
expected,
);
}
function assertThrowsAssertionError(fn: () => unknown): void {
assertThrows(fn, AssertionError);
}
const NOT = blue("[not]");
export {
assertEquals,
assertExpected,
assertFail,
assertSuccess,
assertThrowsAssertionError,
NOT,
};