mirror of
https://github.com/denoland/std.git
synced 2024-11-21 20:50:22 +00:00
c46143f0ac
* chore: update copyright year * fix --------- Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
35 lines
886 B
TypeScript
35 lines
886 B
TypeScript
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
import {
|
|
assertEquals,
|
|
assertExists,
|
|
AssertionError,
|
|
assertThrows,
|
|
} from "./mod.ts";
|
|
|
|
Deno.test("assertExists() matches values that are not null or undefined", () => {
|
|
assertExists("Denosaurus");
|
|
assertExists(false);
|
|
assertExists(0);
|
|
assertExists("");
|
|
assertExists(-0);
|
|
assertExists(0);
|
|
assertExists(NaN);
|
|
|
|
const value = new URLSearchParams({ value: "test" }).get("value");
|
|
assertExists(value);
|
|
assertEquals(value.length, 4);
|
|
});
|
|
|
|
Deno.test("assertExists() throws when value is null or undefined", () => {
|
|
assertThrows(
|
|
() => assertExists(undefined),
|
|
AssertionError,
|
|
'Expected actual: "undefined" to not be null or undefined.',
|
|
);
|
|
assertThrows(
|
|
() => assertExists(null),
|
|
AssertionError,
|
|
'Expected actual: "null" to not be null or undefined.',
|
|
);
|
|
});
|