From ddc0a9643e03bc66e415c76e65a880d92e485de3 Mon Sep 17 00:00:00 2001 From: Tyler Wilding Date: Sat, 21 Sep 2024 22:26:26 -0400 Subject: [PATCH] tests: update tests --- src/lib/i18n/i18n.ts | 2 ++ src/lib/utils/github.test.ts | 24 ++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) 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();