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