mirror of
https://github.com/open-goal/launcher.git
synced 2024-10-19 14:47:36 -04:00
tests: update tests
This commit is contained in:
parent
cf51c1da50
commit
ddc0a9643e
|
@ -215,5 +215,7 @@ export async function initLocales(async: boolean) {
|
||||||
});
|
});
|
||||||
if (!async) {
|
if (!async) {
|
||||||
await initPromise;
|
await initPromise;
|
||||||
|
} else {
|
||||||
|
return initPromise;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 { arch, platform } from "@tauri-apps/api/os";
|
||||||
import { listOfficialReleases } from "./github";
|
import { listOfficialReleases } from "./github";
|
||||||
|
import { init } from "svelte-i18n";
|
||||||
|
import { initLocales } from "$lib/i18n/i18n";
|
||||||
|
|
||||||
vi.mock("@tauri-apps/api/os");
|
vi.mock("@tauri-apps/api/os");
|
||||||
global.fetch = vi.fn();
|
global.fetch = vi.fn();
|
||||||
|
|
||||||
function createFetchResponse(data: any) {
|
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) {
|
function createFakeGithubReleaseAsset(assetName) {
|
||||||
|
@ -121,6 +137,10 @@ function createFakeGithubRelease(assetNames: string[]) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
await initLocales(true);
|
||||||
|
});
|
||||||
|
|
||||||
describe("listOfficialReleases", () => {
|
describe("listOfficialReleases", () => {
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
|
|
Loading…
Reference in a new issue