From a5958b5f45bcaab7e63b9ffdba681dcb9474237d Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Sat, 19 Mar 2022 22:24:21 +0330 Subject: [PATCH] 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. --- Userland/Libraries/LibJS/Tests/test-common.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/Tests/test-common.js b/Userland/Libraries/LibJS/Tests/test-common.js index bbdc80fc9b..3f5e51d24b 100644 --- a/Userland/Libraries/LibJS/Tests/test-common.js +++ b/Userland/Libraries/LibJS/Tests/test-common.js @@ -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(); }