mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-11-25 01:41:05 -05:00
Added enum for Forge environment types
This commit is contained in:
parent
a8cce57c4b
commit
56083ad40b
2 changed files with 73 additions and 0 deletions
44
src/loaders/forge/forge-environment-type.ts
Normal file
44
src/loaders/forge/forge-environment-type.ts
Normal file
|
@ -0,0 +1,44 @@
|
|||
import { Enum, EnumOptions } from "@/utils/enum";
|
||||
|
||||
/**
|
||||
* Represents the different physical sides that a Forge mod can run on.
|
||||
*/
|
||||
enum ForgeEnvironmentTypeValues {
|
||||
/**
|
||||
* Present on the client side.
|
||||
*/
|
||||
CLIENT = "CLIENT",
|
||||
|
||||
/**
|
||||
* Present on the dedicated server.
|
||||
*/
|
||||
SERVER = "SERVER",
|
||||
|
||||
/**
|
||||
* Present on both the client and server side.
|
||||
*/
|
||||
BOTH = "BOTH",
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for configuring the behavior of the `ForgeEnvironmentType` enum.
|
||||
*/
|
||||
const ForgeEnvironmentTypeOptions: EnumOptions = {
|
||||
/**
|
||||
* Ignore the case of the environment type string when parsing.
|
||||
*/
|
||||
ignoreCase: true,
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents the different physical sides that a Forge mod can run on.
|
||||
*/
|
||||
export const ForgeEnvironmentType = Enum.create(
|
||||
ForgeEnvironmentTypeValues,
|
||||
ForgeEnvironmentTypeOptions,
|
||||
);
|
||||
|
||||
/**
|
||||
* Represents the different physical sides that a Forge mod can run on.
|
||||
*/
|
||||
export type ForgeEnvironmentType = Enum<typeof ForgeEnvironmentTypeValues>;
|
29
tests/unit/loaders/forge/forge-environment-type.spec.ts
Normal file
29
tests/unit/loaders/forge/forge-environment-type.spec.ts
Normal file
|
@ -0,0 +1,29 @@
|
|||
import { ForgeEnvironmentType } from "@/loaders/forge/forge-environment-type";
|
||||
|
||||
describe("ForgeEnvironmentType", () => {
|
||||
describe("parse", () => {
|
||||
test("parses all its own formatted values", () => {
|
||||
for (const value of ForgeEnvironmentType.values()) {
|
||||
expect(ForgeEnvironmentType.parse(ForgeEnvironmentType.format(value))).toBe(value);
|
||||
}
|
||||
});
|
||||
|
||||
test("parses all friendly names of its own values", () => {
|
||||
for (const value of ForgeEnvironmentType.values()) {
|
||||
expect(ForgeEnvironmentType.parse(ForgeEnvironmentType.friendlyNameOf(value))).toBe(value);
|
||||
}
|
||||
});
|
||||
|
||||
test("parses all its own formatted values in lowercase", () => {
|
||||
for (const value of ForgeEnvironmentType.values()) {
|
||||
expect(ForgeEnvironmentType.parse(ForgeEnvironmentType.format(value).toLowerCase())).toBe(value);
|
||||
}
|
||||
});
|
||||
|
||||
test("parses all its own formatted values in UPPERCASE", () => {
|
||||
for (const value of ForgeEnvironmentType.values()) {
|
||||
expect(ForgeEnvironmentType.parse(ForgeEnvironmentType.format(value).toUpperCase())).toBe(value);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue