diff options
Diffstat (limited to 'src/bun.js/test')
-rw-r--r-- | src/bun.js/test/jest.zig | 69 |
1 files changed, 33 insertions, 36 deletions
diff --git a/src/bun.js/test/jest.zig b/src/bun.js/test/jest.zig index 07f802c13..590d5ec2b 100644 --- a/src/bun.js/test/jest.zig +++ b/src/bun.js/test/jest.zig @@ -1401,45 +1401,42 @@ pub const TestScope = struct { initial_value = js.JSObjectCallAsFunctionReturnValue(vm.global, callback, null, 0, null); } - if (!initial_value.isEmptyOrUndefinedOrNull()) { - if (initial_value.isAnyError(vm.global)) { - vm.runErrorHandler(initial_value, null); - return .{ .fail = active_test_expectation_counter.actual }; - } - - if (initial_value.asAnyPromise()) |promise| { - if (this.promise != null) { - return .{ .pending = {} }; - } - this.task = task; + if (initial_value.isAnyError(vm.global)) { + vm.runErrorHandler(initial_value, null); + return .{ .fail = active_test_expectation_counter.actual }; + } - // TODO: not easy to coerce JSInternalPromise as JSValue, - // so simply wait for completion for now. - switch (promise) { - .Internal => vm.waitForPromise(promise), - else => {}, - } + if (initial_value.asAnyPromise()) |promise| { + if (this.promise != null) { + return .{ .pending = {} }; + } + this.task = task; - switch (promise.status(vm.global.vm())) { - .Rejected => { - vm.runErrorHandler(promise.result(vm.global.vm()), null); - return .{ .fail = active_test_expectation_counter.actual }; - }, - .Pending => { - task.promise_state = .pending; - switch (promise) { - .Normal => |p| { - _ = p.asValue(vm.global).then(vm.global, task, onResolve, onReject); - return .{ .pending = {} }; - }, - else => unreachable, - } - }, + // TODO: not easy to coerce JSInternalPromise as JSValue, + // so simply wait for completion for now. + switch (promise) { + .Internal => vm.waitForPromise(promise), + else => {}, + } - else => { - _ = promise.result(vm.global.vm()); - }, - } + switch (promise.status(vm.global.vm())) { + .Rejected => { + vm.runErrorHandler(promise.result(vm.global.vm()), null); + return .{ .fail = active_test_expectation_counter.actual }; + }, + .Pending => { + task.promise_state = .pending; + switch (promise) { + .Normal => |p| { + _ = p.asValue(vm.global).then(vm.global, task, onResolve, onReject); + return .{ .pending = {} }; + }, + else => unreachable, + } + }, + else => { + _ = promise.result(vm.global.vm()); + }, } } |