mirror of
https://github.com/rommapp/romm.git
synced 2026-11-30 10:32:57 +01:00
23 lines
588 B
TypeScript
23 lines
588 B
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
import { relativeFolderPath } from "./validation";
|
|
|
|
vi.mock("@/locales", () => ({
|
|
default: { global: { t: (key: string) => key } },
|
|
}));
|
|
|
|
describe("relativeFolderPath", () => {
|
|
it.each(["hack", "hack/v2", "patches/v2/", " cheats "])(
|
|
"accepts %j",
|
|
(value) => {
|
|
expect(relativeFolderPath(value)).toBe(true);
|
|
},
|
|
);
|
|
|
|
it.each(["/hack", "a\\b", "../x", "a/../b", "a//b", "a/./b", "."])(
|
|
"rejects %j",
|
|
(value) => {
|
|
expect(relativeFolderPath(value)).toBe("common.invalid-relative-path");
|
|
},
|
|
);
|
|
});
|