mirror of
https://github.com/denoland/deno.git
synced 2025-01-18 20:04:03 -05:00
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
|
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||
|
|
||
|
import { assertStrContains, assertMatch } from "./asserts.ts";
|
||
|
import { test, assert } from "./mod.ts";
|
||
|
// import { assertEqual as prettyAssertEqual } from "./pretty.ts";
|
||
|
// import "./format_test.ts";
|
||
|
// import "./diff_test.ts";
|
||
|
// import "./pretty_test.ts";
|
||
|
|
||
|
test(function testingAssertStringContains() {
|
||
|
assertStrContains("Denosaurus", "saur");
|
||
|
assertStrContains("Denosaurus", "Deno");
|
||
|
assertStrContains("Denosaurus", "rus");
|
||
|
});
|
||
|
|
||
|
test(function testingAssertStringContainsThrow() {
|
||
|
let didThrow = false;
|
||
|
try {
|
||
|
assertStrContains("Denosaurus from Jurassic", "Raptor");
|
||
|
} catch (e) {
|
||
|
assert(
|
||
|
e.message ===
|
||
|
`actual: "Denosaurus from Jurassic" expected to contains: "Raptor"`
|
||
|
);
|
||
|
didThrow = true;
|
||
|
}
|
||
|
assert(didThrow);
|
||
|
});
|
||
|
|
||
|
test(function testingAssertStringMatching() {
|
||
|
assertMatch("foobar@deno.com", RegExp(/[a-zA-Z]+@[a-zA-Z]+.com/));
|
||
|
});
|
||
|
|
||
|
test(function testingAssertStringMatchingThrows() {
|
||
|
let didThrow = false;
|
||
|
try {
|
||
|
assertMatch("Denosaurus from Jurassic", RegExp(/Raptor/));
|
||
|
} catch (e) {
|
||
|
assert(
|
||
|
e.message ===
|
||
|
`actual: "Denosaurus from Jurassic" expected to match: "/Raptor/"`
|
||
|
);
|
||
|
didThrow = true;
|
||
|
}
|
||
|
assert(didThrow);
|
||
|
});
|