mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-03 14:50:02 +00:00
Tests/LibJS: Split await Promise constructor observability test into two
This makes it easier to figure out the expected behaviour of each of the tests since it was difficult to determine what each case was aiming to test.
This commit is contained in:
parent
69050da929
commit
cba9c099c8
1 changed files with 23 additions and 4 deletions
|
@ -257,7 +257,7 @@ describe("await thenables", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("await observably looks up constructor of Promise objects", () => {
|
describe("await observably looks up constructor of Promise objects increasing call count", () => {
|
||||||
let calls = 0;
|
let calls = 0;
|
||||||
function makeConstructorObservable(promise) {
|
function makeConstructorObservable(promise) {
|
||||||
Object.defineProperty(promise, "constructor", {
|
Object.defineProperty(promise, "constructor", {
|
||||||
|
@ -276,9 +276,6 @@ describe("await observably looks up constructor of Promise objects", () => {
|
||||||
resolve();
|
resolve();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
await makeConstructorObservable(new Boolean(true));
|
|
||||||
await makeConstructorObservable({});
|
|
||||||
await makeConstructorObservable(new Number(2));
|
|
||||||
try {
|
try {
|
||||||
await makeConstructorObservable(Promise.reject(3));
|
await makeConstructorObservable(Promise.reject(3));
|
||||||
} catch {}
|
} catch {}
|
||||||
|
@ -292,3 +289,25 @@ describe("await observably looks up constructor of Promise objects", () => {
|
||||||
runQueuedPromiseJobs();
|
runQueuedPromiseJobs();
|
||||||
expect(calls).toBe(4);
|
expect(calls).toBe(4);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("await observably looks up constructor of Promise objects not increasing call count", () => {
|
||||||
|
let calls = 0;
|
||||||
|
function makeConstructorObservable(promise) {
|
||||||
|
Object.defineProperty(promise, "constructor", {
|
||||||
|
get() {
|
||||||
|
calls++;
|
||||||
|
return Promise;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function test() {
|
||||||
|
await makeConstructorObservable(new Boolean(true));
|
||||||
|
await makeConstructorObservable({});
|
||||||
|
await makeConstructorObservable(new Number(2));
|
||||||
|
}
|
||||||
|
test();
|
||||||
|
runQueuedPromiseJobs();
|
||||||
|
expect(calls).toBe(0);
|
||||||
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue