test: add unit test for assert for increase coverage to 100%

This commit is contained in:
vector 2023-12-08 02:09:08 +08:00
parent b922729093
commit 4364c7264b

View File

@ -1,6 +1,17 @@
import { assertDefined, assertDefinedAndNotNull } from "./assert"; import { assert, assertDefined, assertDefinedAndNotNull } from "./assert";
describe("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");
});
});
describe("assertDefined", () => { describe("assertDefined", () => {
it("passes for simple values", () => { it("passes for simple values", () => {
{ {