mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-28 07:18:51 +00:00
33 lines
1,016 B
JavaScript
33 lines
1,016 B
JavaScript
test("length is 1", () => {
|
|
expect(Promise.reject).toHaveLength(1);
|
|
});
|
|
|
|
describe("normal behavior", () => {
|
|
test("returns a Promise", () => {
|
|
const rejectedPromise = Promise.reject();
|
|
expect(rejectedPromise).toBeInstanceOf(Promise);
|
|
});
|
|
|
|
test("returned Promise is rejected with given argument", () => {
|
|
let rejectionReason = null;
|
|
Promise.reject("Some value").catch(reason => {
|
|
rejectionReason = reason;
|
|
});
|
|
runQueuedPromiseJobs();
|
|
expect(rejectionReason).toBe("Some value");
|
|
});
|
|
|
|
test("works with subclasses", () => {
|
|
class CustomPromise extends Promise {}
|
|
|
|
const rejectedPromise = CustomPromise.reject("Some value");
|
|
expect(rejectedPromise).toBeInstanceOf(CustomPromise);
|
|
|
|
let rejectionReason = null;
|
|
rejectedPromise.catch(reason => {
|
|
rejectionReason = reason;
|
|
});
|
|
runQueuedPromiseJobs();
|
|
expect(rejectionReason).toBe("Some value");
|
|
});
|
|
});
|