mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-11-22 00:11:02 -05:00
Made enum for every known loader
This commit is contained in:
parent
74cdd685f2
commit
917a5130f1
2 changed files with 77 additions and 0 deletions
48
src/loaders/loader-type.ts
Normal file
48
src/loaders/loader-type.ts
Normal 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>;
|
29
tests/unit/loaders/loader-type.spec.ts
Normal file
29
tests/unit/loaders/loader-type.spec.ts
Normal 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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in a new issue