Made enum for every known loader

This commit is contained in:
Kir_Antipov 2023-03-07 13:29:10 +00:00
parent 74cdd685f2
commit 917a5130f1
2 changed files with 77 additions and 0 deletions

View file

@ -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<typeof LoaderTypeValues>;

View file

@ -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);
}
});
});
});