diff --git a/web-wallet/src/lib/components/__tests__/OperationResult.spec.js b/web-wallet/src/lib/components/__tests__/OperationResult.spec.js index 0c058938ad..d53e195ba9 100644 --- a/web-wallet/src/lib/components/__tests__/OperationResult.spec.js +++ b/web-wallet/src/lib/components/__tests__/OperationResult.spec.js @@ -1,7 +1,7 @@ import { afterEach, describe, expect, it, vi } from "vitest"; import { cleanup, render } from "@testing-library/svelte"; -import { rejectAfter, resolveAfter } from "$lib/dusk/test-helpers"; +import { rejectAfter, resolveAfter } from "$lib/dusk/promise"; import { OperationResult } from ".."; diff --git a/web-wallet/src/lib/components/__tests__/Transactions.spec.js b/web-wallet/src/lib/components/__tests__/Transactions.spec.js index b86a15dda2..64f1866089 100644 --- a/web-wallet/src/lib/components/__tests__/Transactions.spec.js +++ b/web-wallet/src/lib/components/__tests__/Transactions.spec.js @@ -3,7 +3,7 @@ import { afterAll, afterEach, describe, expect, it, vi } from "vitest"; import { get } from "svelte/store"; import { base } from "$app/paths"; -import { resolveAfter } from "$lib/dusk/test-helpers"; +import { resolveAfter } from "$lib/dusk/promise"; import { settingsStore } from "$lib/stores"; import { transactions } from "$lib/mock-data"; import { sortByHeightDesc } from "$lib/transactions"; diff --git a/web-wallet/src/lib/dusk/components/__tests__/Suspense.spec.js b/web-wallet/src/lib/dusk/components/__tests__/Suspense.spec.js index 48aa1d61c8..18c2c9f586 100644 --- a/web-wallet/src/lib/dusk/components/__tests__/Suspense.spec.js +++ b/web-wallet/src/lib/dusk/components/__tests__/Suspense.spec.js @@ -1,7 +1,7 @@ import { afterEach, describe, expect, it, vi } from "vitest"; import { cleanup, render } from "@testing-library/svelte"; -import { rejectAfter, resolveAfter } from "$lib/dusk/test-helpers"; +import { rejectAfter, resolveAfter } from "$lib/dusk/promise"; import { Suspense } from ".."; diff --git a/web-wallet/src/lib/dusk/test-helpers/__tests__/rejectAfter.spec.js b/web-wallet/src/lib/dusk/test-helpers/__tests__/rejectAfter.spec.js deleted file mode 100644 index b170546e09..0000000000 --- a/web-wallet/src/lib/dusk/test-helpers/__tests__/rejectAfter.spec.js +++ /dev/null @@ -1,30 +0,0 @@ -import { afterAll, describe, expect, it, vi } from "vitest"; - -import { rejectAfter } from ".."; - -describe("rejectAfter", () => { - vi.useFakeTimers(); - - afterAll(() => { - vi.useRealTimers(); - }); - - it("build a promise that rejects with the given error after the chosen delay", async () => { - let result; - - const error = new Error("some error message"); - const delay = 2000; - - rejectAfter(delay, error).catch((r) => { - result = r; - }); - - await vi.advanceTimersByTimeAsync(delay / 2); - - expect(result).toBeUndefined(); - - await vi.advanceTimersByTimeAsync(delay / 2); - - expect(result).toBe(error); - }); -}); diff --git a/web-wallet/src/lib/dusk/test-helpers/__tests__/resolveAfter.spec.js b/web-wallet/src/lib/dusk/test-helpers/__tests__/resolveAfter.spec.js deleted file mode 100644 index 0367395ff7..0000000000 --- a/web-wallet/src/lib/dusk/test-helpers/__tests__/resolveAfter.spec.js +++ /dev/null @@ -1,30 +0,0 @@ -import { afterAll, describe, expect, it, vi } from "vitest"; - -import { resolveAfter } from ".."; - -describe("resolveAfter", () => { - vi.useFakeTimers(); - - afterAll(() => { - vi.useRealTimers(); - }); - - it("build a promise that resolves with the given value after the chosen delay", async () => { - let result; - - const value = {}; - const delay = 2000; - - resolveAfter(delay, value).then((r) => { - result = r; - }); - - await vi.advanceTimersByTimeAsync(delay / 2); - - expect(result).toBeUndefined(); - - await vi.advanceTimersByTimeAsync(delay / 2); - - expect(result).toBe(value); - }); -}); diff --git a/web-wallet/src/lib/dusk/test-helpers/index.js b/web-wallet/src/lib/dusk/test-helpers/index.js index 3d24c746af..7555f7b869 100644 --- a/web-wallet/src/lib/dusk/test-helpers/index.js +++ b/web-wallet/src/lib/dusk/test-helpers/index.js @@ -2,6 +2,4 @@ export { default as getAsHTMLElement } from "./getAsHTMLElement"; export { default as mockReadableStore } from "./mockReadableStore"; export { default as renderWithSimpleContent } from "./renderWithSimpleContent"; export { default as renderWithSlots } from "./renderWithSlots"; -export { default as rejectAfter } from "./rejectAfter"; -export { default as resolveAfter } from "./resolveAfter"; export { default as SlotContent } from "./SlotContent.svelte"; diff --git a/web-wallet/src/lib/dusk/test-helpers/rejectAfter.js b/web-wallet/src/lib/dusk/test-helpers/rejectAfter.js deleted file mode 100644 index c31a30ab1f..0000000000 --- a/web-wallet/src/lib/dusk/test-helpers/rejectAfter.js +++ /dev/null @@ -1,7 +0,0 @@ -/** @type {(delay: number, error: Error) => Promise} */ -const rejectAfter = (delay, error) => - new Promise((_, reject) => { - setTimeout(() => reject(error), delay); - }); - -export default rejectAfter; diff --git a/web-wallet/src/lib/dusk/test-helpers/resolveAfter.js b/web-wallet/src/lib/dusk/test-helpers/resolveAfter.js deleted file mode 100644 index 960d85c285..0000000000 --- a/web-wallet/src/lib/dusk/test-helpers/resolveAfter.js +++ /dev/null @@ -1,7 +0,0 @@ -/** @type {(delay: number, value: any) => Promise} */ -const resolveAfter = (delay, value) => - new Promise((resolve) => { - setTimeout(() => resolve(value), delay); - }); - -export default resolveAfter; diff --git a/web-wallet/src/lib/stores/__tests__/walletStore.spec.js b/web-wallet/src/lib/stores/__tests__/walletStore.spec.js index 8a4d2c6d5b..9124e518cc 100644 --- a/web-wallet/src/lib/stores/__tests__/walletStore.spec.js +++ b/web-wallet/src/lib/stores/__tests__/walletStore.spec.js @@ -4,7 +4,7 @@ import { keys } from "lamb"; import { Gas, Wallet } from "@dusk-network/dusk-wallet-js"; import { addresses, transactions } from "$lib/mock-data"; -import { rejectAfter, resolveAfter } from "$lib/dusk/test-helpers"; +import { rejectAfter, resolveAfter } from "$lib/dusk/promise"; import { walletStore } from ".."; import { waitFor } from "@testing-library/svelte";