From 2c6ab90c5fe96ced076b35dfab0475aee6903922 Mon Sep 17 00:00:00 2001 From: Kir_Antipov Date: Sun, 7 Jan 2024 14:39:32 +0000 Subject: [PATCH] Added tests for `curseforge-project` --- .../curseforge/curseforge-project.spec.ts | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/unit/platforms/curseforge/curseforge-project.spec.ts diff --git a/tests/unit/platforms/curseforge/curseforge-project.spec.ts b/tests/unit/platforms/curseforge/curseforge-project.spec.ts new file mode 100644 index 0000000..7db72dd --- /dev/null +++ b/tests/unit/platforms/curseforge/curseforge-project.spec.ts @@ -0,0 +1,31 @@ +import { isCurseForgeProjectId } from "@/platforms/curseforge/curseforge-project"; + +describe("isCurseForgeProjectId", () => { + test("returns true when input is a number", () => { + expect(isCurseForgeProjectId(123456)).toBe(true); + }); + + test("returns true when input is a string containing an integer", () => { + expect(isCurseForgeProjectId("123456")).toBe(true); + }); + + test("returns false when input is a string containing non-integer characters", () => { + expect(isCurseForgeProjectId("123abc")).toBe(false); + }); + + test("returns false when input is a string containing floating point number", () => { + expect(isCurseForgeProjectId("123.456")).toBe(false); + }); + + test("returns false when input is an empty string", () => { + expect(isCurseForgeProjectId("")).toBe(false); + }); + + test("returns false when input is null", () => { + expect(isCurseForgeProjectId(null)).toBe(false); + }); + + test("returns false when input is undefined", () => { + expect(isCurseForgeProjectId(undefined)).toBe(false); + }); +});