test: add custom message test case for assert

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

View File

@ -10,6 +10,11 @@ describe("assert", () => {
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", () => {