Merge pull request #1518 from hyperbolic-versor/ut2

test: add unit test for `assert` for increase coverage to 100%
This commit is contained in:
Simon Warta 2023-12-08 23:13:05 +01:00 committed by GitHub
commit 97a54b8a10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,21 @@
import { assertDefined, assertDefinedAndNotNull } from "./assert";
import { assert, assertDefined, assertDefinedAndNotNull } from "./assert";
describe("assert", () => {
describe("assert", () => {
it("assert should not throw an error when condition is truthy", () => {
expect(() => assert(true)).not.toThrow();
});
it("assert should throw an error with default message when condition is falsy", () => {
expect(() => assert(false)).toThrowError("condition is not truthy");
});
it("assert should throw an error with custom message when condition is falsy", () => {
const errorMessage = "Custom error message";
expect(() => assert(false, errorMessage)).toThrowError(errorMessage);
});
});
describe("assertDefined", () => {
it("passes for simple values", () => {
{