Browse Source

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.
Ali Mohammad Pur 3 years ago
parent
commit
a5958b5f45
1 changed files with 2 additions and 1 deletions
  1. 2 1
      Userland/Libraries/LibJS/Tests/test-common.js

+ 2 - 1
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();
                 }