diff --git a/src/lib/i18n/i18n.ts b/src/lib/i18n/i18n.ts index 06e068d..7e476a5 100644 --- a/src/lib/i18n/i18n.ts +++ b/src/lib/i18n/i18n.ts @@ -215,5 +215,7 @@ export async function initLocales(async: boolean) { }); if (!async) { await initPromise; + } else { + return initPromise; } } diff --git a/src/lib/utils/github.test.ts b/src/lib/utils/github.test.ts index fde07bd..62ac3dd 100644 --- a/src/lib/utils/github.test.ts +++ b/src/lib/utils/github.test.ts @@ -1,12 +1,28 @@ -import { afterEach, describe, expect, it, vi, type Mock } from "vitest"; +import { + afterEach, + beforeAll, + beforeEach, + describe, + expect, + it, + vi, + type Mock, +} from "vitest"; import { arch, platform } from "@tauri-apps/api/os"; import { listOfficialReleases } from "./github"; +import { init } from "svelte-i18n"; +import { initLocales } from "$lib/i18n/i18n"; vi.mock("@tauri-apps/api/os"); global.fetch = vi.fn(); function createFetchResponse(data: any) { - return { json: () => new Promise((resolve) => resolve(data)) }; + return { + ok: true, + status: 200, + headers: new Map(), + json: () => new Promise((resolve) => resolve(data)), + }; } function createFakeGithubReleaseAsset(assetName) { @@ -121,6 +137,10 @@ function createFakeGithubRelease(assetNames: string[]) { }; } +beforeAll(async () => { + await initLocales(true); +}); + describe("listOfficialReleases", () => { afterEach(() => { vi.clearAllMocks();