2024-07-05 08:30:48 -07:00
|
|
|
import i18next, { type ParseKeys } from "i18next";
|
|
|
|
import { vi } from "vitest";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets up the i18next mock.
|
|
|
|
* Includes a i18next.t mocked implementation only returning the raw key (`(key) => key`)
|
|
|
|
*
|
|
|
|
* @returns A spy/mock of i18next
|
|
|
|
*/
|
|
|
|
export function mockI18next() {
|
|
|
|
return vi.spyOn(i18next, "t").mockImplementation((key: ParseKeys) => key);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates an array of range `start - end`
|
|
|
|
*
|
|
|
|
* @param start start number e.g. 1
|
|
|
|
* @param end end number e.g. 10
|
|
|
|
* @returns an array of numbers
|
|
|
|
*/
|
2025-02-05 01:56:13 +01:00
|
|
|
export function arrayOfRange(start: number, end: number) {
|
2024-07-05 08:30:48 -07:00
|
|
|
return Array.from({ length: end - start }, (_v, k) => k + start);
|
|
|
|
}
|
2024-11-04 12:57:21 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Utility to get the API base URL from the environment variable (or the default/fallback).
|
|
|
|
* @returns the API base URL
|
|
|
|
*/
|
|
|
|
export function getApiBaseUrl() {
|
|
|
|
return import.meta.env.VITE_SERVER_URL ?? "http://localhost:8001";
|
|
|
|
}
|