@forge/react

11.8.3-next.0-experimental-0c74a4b11.9.0-next.1
out/hooks/__test__/useObjectStore.test.js
out/hooks/__test__/useObjectStore.test.js
+5−4
Index: package/out/hooks/__test__/useObjectStore.test.js
===================================================================
--- package/out/hooks/__test__/useObjectStore.test.js
+++ package/out/hooks/__test__/useObjectStore.test.js
@@ -16,8 +16,9 @@
 const mockGetMetadata = jest.fn();
 const reconcilerTestRenderer_1 = tslib_1.__importDefault(require("../../__test__/reconcilerTestRenderer"));
 const testUtils_1 = require("../../__test__/testUtils");
 const useObjectStore_1 = require("../useObjectStore");
+const utils_1 = require("./utils");
 // Mock @forge/bridge
 jest.mock('@forge/bridge', () => ({
     objectStore: {
         upload: mockUpload,
@@ -169,9 +170,9 @@
                 functionKey: MOCK_FUNCTION_KEY,
                 objects: [MOCK_BLOB]
             });
             // Give a tick for state to update
-            await new Promise((resolve) => setTimeout(resolve, 0));
+            await (0, utils_1.sleep)();
             // Should have temp object with isUploading: true
             expect(hookResult.objectStates).toHaveLength(1);
             expect(hookResult.objectStates[0].isUploading).toBe(true);
             expect(hookResult.objectStates[0].key).toMatch(/^temp-upload-/);
@@ -277,9 +278,9 @@
                 functionKey: MOCK_FUNCTION_KEY,
                 keys: [MOCK_OBJECT_KEY_1]
             });
             // Give a tick for state to update
-            await new Promise((resolve) => setTimeout(resolve, 0));
+            await (0, utils_1.sleep)();
             // Should have isDeleting: true
             expect(hookResult.objectStates[0].isDeleting).toBe(true);
             // Resolve delete
             resolveDelete(undefined);
@@ -360,9 +361,9 @@
                 functionKey: MOCK_FUNCTION_KEY,
                 keys: [MOCK_OBJECT_KEY_1, MOCK_OBJECT_KEY_2]
             });
             // Give a tick for state to update
-            await new Promise((resolve) => setTimeout(resolve, 0));
+            await (0, utils_1.sleep)();
             // Both should have isDeleting: true
             expect(hookResult.objectStates[0].isDeleting).toBe(true);
             expect(hookResult.objectStates[1].isDeleting).toBe(true);
             // Resolve delete
@@ -417,9 +418,9 @@
                 functionKey: MOCK_FUNCTION_KEY,
                 keys: [MOCK_OBJECT_KEY_1]
             });
             // Give a tick for state to update
-            await new Promise((resolve) => setTimeout(resolve, 0));
+            await (0, utils_1.sleep)();
             // Should have isDownloading: true
             expect(hookResult.objectStates[0].isDownloading).toBe(true);
             // Resolve download
             const mockBlob = new Blob(['content']);