2026-06-15 14:24:33 +01:00
|
|
|
/*
|
|
|
|
|
Copyright 2026 Element Creations Ltd.
|
|
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
|
|
|
Please see LICENSE files in the repository root for full details.
|
|
|
|
|
*/
|
|
|
|
|
|
2026-06-19 16:34:18 +01:00
|
|
|
import { vi, beforeEach } from "vitest";
|
2026-06-15 14:24:33 +01:00
|
|
|
import fetchMock, { manageFetchMockGlobally } from "@fetch-mock/vitest";
|
|
|
|
|
|
2026-06-19 16:34:18 +01:00
|
|
|
import { mocks } from "../../test/setup/mocks.ts";
|
|
|
|
|
import SdkConfig, { DEFAULTS } from "../SdkConfig";
|
|
|
|
|
|
2026-06-15 14:24:33 +01:00
|
|
|
manageFetchMockGlobally();
|
|
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
// set up fetch API mock
|
|
|
|
|
fetchMock.hardReset();
|
|
|
|
|
fetchMock.catch(404);
|
|
|
|
|
fetchMock.mockGlobal();
|
|
|
|
|
});
|
2026-06-19 16:34:18 +01:00
|
|
|
|
|
|
|
|
// set up AudioContext API mock
|
|
|
|
|
vi.stubGlobal("AudioContext", function () {
|
|
|
|
|
return mocks.AudioContext;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (globalThis.window === undefined) {
|
|
|
|
|
// We are in a node environment, stub a basic window so singletons work
|
|
|
|
|
vi.stubGlobal("window", {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// uninitialised SdkConfig causes lots of warnings in console, init with defaults
|
|
|
|
|
SdkConfig.put(DEFAULTS);
|