forked from denoland/std
-
Notifications
You must be signed in to change notification settings - Fork 0
/
assert_string_includes_test.ts
37 lines (35 loc) · 943 Bytes
/
assert_string_includes_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
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import {
assert,
assertEquals,
AssertionError,
assertStringIncludes,
} from "./mod.ts";
Deno.test("AssertStringIncludes", function () {
assertStringIncludes("Denosaurus", "saur");
assertStringIncludes("Denosaurus", "Deno");
assertStringIncludes("Denosaurus", "rus");
let didThrow;
try {
assertStringIncludes("Denosaurus", "Raptor");
didThrow = false;
} catch (e) {
assert(e instanceof AssertionError);
didThrow = true;
}
assertEquals(didThrow, true);
});
Deno.test("AssertStringContainsThrow", function () {
let didThrow = false;
try {
assertStringIncludes("Denosaurus from Jurassic", "Raptor");
} catch (e) {
assert(e instanceof AssertionError);
assert(
e.message ===
`Expected actual: "Denosaurus from Jurassic" to contain: "Raptor".`,
);
didThrow = true;
}
assert(didThrow);
});