This repository has been archived on 2023-01-14. You can view files and clone it, but cannot push or open issues or pull requests.
libsiaweb/test/skylinkValidate.test.ts

30 lines
1.2 KiB
TypeScript
Raw Normal View History

2023-01-14 07:21:04 +00:00
import { validateSkyfilePath } from "../src/skylinkValidate.js";
test.each([
{ path: "test", result: null },
{ path: "test/subtrial", result: null },
{ path: "test/subtrial.ext", result: null },
{ path: "test/trial.ext/subtrial.ext", result: null },
{ path: ".foo", result: null },
{ path: ".foo/.bar", result: null },
{ path: "foo/.bar", result: null },
{ path: "/", result: "metdata.Filename cannot start with /" },
{ path: "", result: "path cannot be blank" },
{ path: ".", result: "path cannot be ." },
{ path: "./", result: "metdata.Filename cannot start with ./" },
{
path: "a//b",
result: "path cannot have an empty element, cannot contain //",
},
{ path: "a/./b", result: "path cannot have a . element" },
{ path: "a/../b", result: "path cannot have a .. element" },
{ path: "../a/b", result: "metdata.Filename cannot start with ../" },
{ path: "/sometrial", result: "metdata.Filename cannot start with /" },
{
path: "sometrial/",
result: "path cannot have an empty element, cannot contain //",
},
])("testValidateSkyfilePath with path '$path'", ({ path, result }) => {
expect(validateSkyfilePath(path)).toBe(result);
});