Migrate batch of tests to vitest (#34108)

* Migrate utils/dm tests to vitest

* Migrate utils/room tests to vitest

* Migrate utils/location tests to vitest

* Fix types

* Satisfy tsc & knip
This commit is contained in:
Michael Telatynski
2026-07-03 09:50:11 +01:00
committed by GitHub
parent 8aba166f1e
commit df4a1f0c85
21 changed files with 209 additions and 166 deletions
@@ -0,0 +1,32 @@
/*
Copyright 2024 New Vector Ltd.
Copyright 2023 The Matrix.org Foundation C.I.C.
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
import { describe, it, expect } from "vitest";
import { positionFailureMessage } from "./positionFailureMessage";
describe("positionFailureMessage()", () => {
// error codes from GeolocationPositionError
// see: https://developer.mozilla.org/en-US/docs/Web/API/GeolocationPositionError
// 1: PERMISSION_DENIED
// 2: POSITION_UNAVAILABLE
// 3: TIMEOUT
type TestCase = [number, string | undefined];
it.each<TestCase>([
[
1,
"Element was denied permission to fetch your location. Please allow location access in your browser settings.",
],
[2, "Failed to fetch your location. Please try again later."],
[3, "Timed out trying to fetch your location. Please try again later."],
[4, "Unknown error fetching location. Please try again later."],
[5, undefined],
])("returns correct message for error code %s", (code, expectedMessage) => {
expect(positionFailureMessage(code)).toEqual(expectedMessage);
});
});