LibJS: Allow 'expect().fail("some random string")' in test-js

Previously fail() wanted the fail object to be a callable, allow it to
be a string also.
This commit is contained in:
Ali Mohammad Pur 2022-03-19 22:24:21 +03:30 committed by Ali Mohammad Pur
parent 1d95745901
commit a5958b5f45
Notes: sideshowbarker 2024-07-17 18:13:59 +09:00

View file

@ -512,7 +512,8 @@ class ExpectationError extends Error {
__expect(value, details) {
if (value !== true) {
if (details !== undefined) {
throw new ExpectationError(details());
if (details instanceof Function) throw new ExpectationError(details());
else throw new ExpectationError(details);
} else {
throw new ExpectationError();
}