diff --git a/src/loaders/loader-type.ts b/src/loaders/loader-type.ts new file mode 100644 index 0000000..8e9a16b --- /dev/null +++ b/src/loaders/loader-type.ts @@ -0,0 +1,48 @@ +import { Enum, EnumOptions } from "@/utils/enum"; + +/** + * Represents different mod loader types. + * + * @partial + */ +enum LoaderTypeValues { + /** + * Fabric mod loader. + */ + FABRIC = "fabric", + + /** + * Forge mod loader. + */ + FORGE = "forge", + + /** + * Quilt mod loader. + */ + QUILT = "quilt", +} + +/** + * Options for configuring the behavior of the `LoaderType` enum. + * + * @partial + */ +const LoaderTypeOptions: EnumOptions = { + /** + * The case should be ignored while parsing the mod loader type. + */ + ignoreCase: true, +}; + +/** + * Represents different mod loader types. + */ +export const LoaderType = Enum.create( + LoaderTypeValues, + LoaderTypeOptions, +); + +/** + * Represents different mod loader types. + */ +export type LoaderType = Enum; diff --git a/tests/unit/loaders/loader-type.spec.ts b/tests/unit/loaders/loader-type.spec.ts new file mode 100644 index 0000000..8ee894e --- /dev/null +++ b/tests/unit/loaders/loader-type.spec.ts @@ -0,0 +1,29 @@ +import { LoaderType } from "@/loaders/loader-type"; + +describe("LoaderType", () => { + describe("parse", () => { + test("parses all its own formatted values", () => { + for (const value of LoaderType.values()) { + expect(LoaderType.parse(LoaderType.format(value))).toBe(value); + } + }); + + test("parses all friendly names of its own values", () => { + for (const value of LoaderType.values()) { + expect(LoaderType.parse(LoaderType.friendlyNameOf(value))).toBe(value); + } + }); + + test("parses all its own formatted values in lowercase", () => { + for (const value of LoaderType.values()) { + expect(LoaderType.parse(LoaderType.format(value).toLowerCase())).toBe(value); + } + }); + + test("parses all its own formatted values in UPPERCASE", () => { + for (const value of LoaderType.values()) { + expect(LoaderType.parse(LoaderType.format(value).toUpperCase())).toBe(value); + } + }); + }); +});