mirror of
https://github.com/MasterAcnolo/Freedom-Loader.git
synced 2026-11-13 15:09:20 +01:00
test: add unit tests for configuration and download controllers and handle electron app initialization and improve devMode logic
This commit is contained in:
40
test/unit/validation.helpers.test.js
Normal file
40
test/unit/validation.helpers.test.js
Normal file
@@ -0,0 +1,40 @@
|
||||
const {isValidUrl, isSafePath} = require("../../server/helpers/validation.helpers");
|
||||
|
||||
describe("validation.helpers", () => {
|
||||
describe("isValidUrl", () => {
|
||||
test("returns true for valid http url", () => {
|
||||
expect(isValidUrl("http://example.com")).toBe(true);
|
||||
});
|
||||
|
||||
test("returns true for valid https url", () => {
|
||||
expect(isValidUrl("https://youtube.com/watch?v=123")).toBe(true);
|
||||
});
|
||||
|
||||
test("returns false for invalid url", () => {
|
||||
expect(isValidUrl("not-a-url")).toBe(false);
|
||||
});
|
||||
|
||||
test("returns false for empty string", () => {
|
||||
expect(isValidUrl("")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("isSafePath", () => {
|
||||
test("returns false for empty or short path", () => {
|
||||
expect(isSafePath("")).toBe(false);
|
||||
expect(isSafePath("ab")).toBe(false);
|
||||
});
|
||||
|
||||
test("returns false for Windows System32 path", () => {
|
||||
expect(isSafePath("C:\\Windows\\System32\\test")).toBe(false);
|
||||
});
|
||||
|
||||
test("returns false for Windows path containing Windows", () => {
|
||||
expect(isSafePath("C:\\Windows\\SomeFolder")).toBe(false);
|
||||
});
|
||||
|
||||
test("returns true for safe user path", () => {
|
||||
expect(isSafePath("/home/user/Downloads")).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user