mirror of
https://github.com/denoland/std.git
synced 2024-11-22 04:59:05 +00:00
5803cc9172
* BREAKING(assert): remove `assert` from module names * work * fix * work * work * tweaks * fix
45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
import {
|
|
assert,
|
|
assertEquals,
|
|
AssertionError,
|
|
assertStringIncludes,
|
|
assertThrows,
|
|
} from "./mod.ts";
|
|
|
|
Deno.test("assertStringIncludes()", () => {
|
|
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("assertStringIncludes() throws", () => {
|
|
assertThrows(
|
|
() => assertStringIncludes("Denosaurus from Jurassic", "Raptor"),
|
|
AssertionError,
|
|
`Expected actual: "Denosaurus from Jurassic" to contain: "Raptor".`,
|
|
);
|
|
});
|
|
|
|
Deno.test("assertStringIncludes() with custom message", () => {
|
|
assertThrows(
|
|
() =>
|
|
assertStringIncludes(
|
|
"Denosaurus from Jurassic",
|
|
"Raptor",
|
|
"CUSTOM MESSAGE",
|
|
),
|
|
AssertionError,
|
|
`Expected actual: "Denosaurus from Jurassic" to contain: "Raptor": CUSTOM MESSAGE`,
|
|
);
|
|
});
|