mirror of
https://github.com/SamKirkland/FTP-Deploy-Action.git
synced 2026-04-10 12:32:17 +02:00
Resolving sync state issue, added tests
fixes #124 fixes #122 fixes #120
This commit is contained in:
135
src/main.test.ts
Normal file
135
src/main.test.ts
Normal file
@@ -0,0 +1,135 @@
|
||||
import { optionalBoolean, optionalInt, optionalLogLevel, optionalProtocol, optionalSecurity, optionalString, optionalStringArray } from "./parse";
|
||||
|
||||
describe("boolean", () => {
|
||||
test("false", () => {
|
||||
expect(optionalBoolean("test", "false")).toBe(false);
|
||||
});
|
||||
|
||||
test("FALSE", () => {
|
||||
expect(optionalBoolean("test", "FALSE")).toBe(false);
|
||||
});
|
||||
|
||||
test("true", () => {
|
||||
expect(optionalBoolean("test", "true")).toBe(true);
|
||||
});
|
||||
|
||||
test("TRUE", () => {
|
||||
expect(optionalBoolean("test", "TRUE")).toBe(true);
|
||||
});
|
||||
|
||||
test("optional", () => {
|
||||
expect(optionalBoolean("test", "")).toBe(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe("string", () => {
|
||||
test("empty", () => {
|
||||
expect(optionalString("")).toBe(undefined);
|
||||
});
|
||||
|
||||
test("populated", () => {
|
||||
expect(optionalString("test")).toBe("test");
|
||||
});
|
||||
});
|
||||
|
||||
describe("int", () => {
|
||||
test("empty", () => {
|
||||
expect(optionalInt("test", "")).toBe(undefined);
|
||||
});
|
||||
|
||||
test("0", () => {
|
||||
expect(optionalInt("test", "0")).toBe(0);
|
||||
});
|
||||
|
||||
test("1", () => {
|
||||
expect(optionalInt("test", "1")).toBe(1);
|
||||
});
|
||||
|
||||
test("500", () => {
|
||||
expect(optionalInt("test", "500")).toBe(500);
|
||||
});
|
||||
|
||||
test("non-int", () => {
|
||||
expect(() => optionalInt("test", "12.345")).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe("protocol", () => {
|
||||
test("empty", () => {
|
||||
expect(optionalProtocol("test", "")).toBe(undefined);
|
||||
});
|
||||
|
||||
test("ftp", () => {
|
||||
expect(optionalProtocol("test", "ftp")).toBe("ftp");
|
||||
});
|
||||
|
||||
test("ftps", () => {
|
||||
expect(optionalProtocol("test", "ftps")).toBe("ftps");
|
||||
});
|
||||
|
||||
test("ftps-legacy", () => {
|
||||
expect(optionalProtocol("test", "ftps-legacy")).toBe("ftps-legacy");
|
||||
});
|
||||
});
|
||||
|
||||
describe("log level", () => {
|
||||
test("empty", () => {
|
||||
expect(optionalLogLevel("test", "")).toBe(undefined);
|
||||
});
|
||||
|
||||
test("minimal", () => {
|
||||
expect(optionalLogLevel("test", "minimal")).toBe("minimal");
|
||||
});
|
||||
|
||||
test("standard", () => {
|
||||
expect(optionalLogLevel("test", "standard")).toBe("standard");
|
||||
});
|
||||
|
||||
test("verbose", () => {
|
||||
expect(optionalLogLevel("test", "verbose")).toBe("verbose");
|
||||
});
|
||||
});
|
||||
|
||||
describe("security", () => {
|
||||
test("empty", () => {
|
||||
expect(optionalSecurity("test", "")).toBe(undefined);
|
||||
});
|
||||
|
||||
test("loose", () => {
|
||||
expect(optionalSecurity("test", "loose")).toBe("loose");
|
||||
});
|
||||
|
||||
test("strict", () => {
|
||||
expect(optionalSecurity("test", "strict")).toBe("strict");
|
||||
});
|
||||
});
|
||||
|
||||
describe("array", () => {
|
||||
test("empty", () => {
|
||||
expect(optionalStringArray("test", "")).toEqual(undefined);
|
||||
});
|
||||
|
||||
test("empty array", () => {
|
||||
expect(optionalStringArray("test", "[]")).toEqual([]);
|
||||
});
|
||||
|
||||
test(`["test.txt"]`, () => {
|
||||
expect(optionalStringArray("test", "[test.txt]")).toEqual(["test.txt"]);
|
||||
});
|
||||
|
||||
test(`[ "test.txt" ]`, () => {
|
||||
expect(optionalStringArray("test", "[ test.txt ]")).toEqual(["test.txt"]);
|
||||
});
|
||||
|
||||
test(`["test.txt", "folder/**/*"]`, () => {
|
||||
expect(optionalStringArray("test", "[test.txt, folder/**/*]")).toEqual(["test.txt", "folder/**/*"]);
|
||||
});
|
||||
|
||||
test(`["test.txt", "folder/**/*", "*other"]`, () => {
|
||||
expect(optionalStringArray("test", `test.txt\n - folder/**/*\n - *other`)).toEqual(["test.txt", "folder/**/*", "*other"]);
|
||||
});
|
||||
|
||||
test(`["test.txt", "folder/**/*", "*other"]`, () => {
|
||||
expect(optionalStringArray("test", `\n - test.txt\n - folder/**/*\n - *other`)).toEqual(["test.txt", "folder/**/*", "*other"]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user