/[sudobot]/trunk/tests/framework/polyfills/Promise.test.ts
ViewVC logotype

Contents of /trunk/tests/framework/polyfills/Promise.test.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 632 - (show annotations)
Thu Oct 10 17:53:11 2024 UTC (5 months, 3 weeks ago) by rakinar2
File MIME type: application/typescript
File size: 763 byte(s)
chore: synchronize

1 import { PromiseWithResolversReturn, promiseWithResolvers } from "@framework/polyfills/Promise";
2 import { describe, expect, it } from "vitest";
3
4 declare global {
5 interface PromiseConstructor {
6 // @ts-ignore
7 withResolvers?<T>(): PromiseWithResolversReturn<T>;
8 }
9 }
10
11 describe("Promise polyfill", () => {
12 it("should polyfill Promise.withResolvers", async () => {
13 // Arrange
14 const originalPromise = Promise;
15
16 // Act
17 delete Promise.withResolvers;
18 const { promise, resolve, reject } = promiseWithResolvers<void>();
19
20 // Assert
21 expect(promise).toBeInstanceOf(originalPromise);
22 expect(resolve).toBeInstanceOf(Function);
23 expect(reject).toBeInstanceOf(Function);
24 });
25 });

team@onesoftnet.eu.org
ViewVC Help
Powered by ViewVC 1.1.26