mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-11-25 01:41:05 -05:00
Added enum for Quilt environment types
This commit is contained in:
parent
8df878c5ba
commit
71525b9c9f
2 changed files with 78 additions and 0 deletions
49
src/loaders/quilt/quilt-environment-type.ts
Normal file
49
src/loaders/quilt/quilt-environment-type.ts
Normal file
|
@ -0,0 +1,49 @@
|
|||
import { Enum, EnumOptions } from "@/utils/enum";
|
||||
|
||||
/**
|
||||
* Represents the different environments that a Quilt mod can run on.
|
||||
*/
|
||||
enum QuiltEnvironmentTypeValues {
|
||||
/**
|
||||
* The physical client.
|
||||
*/
|
||||
CLIENT = "client",
|
||||
|
||||
/**
|
||||
* The dedicated server.
|
||||
*/
|
||||
DEDICATED_SERVER = "dedicated_server",
|
||||
|
||||
/**
|
||||
* Runs on all environments.
|
||||
*/
|
||||
ALL = "*",
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for configuring the behavior of the `QuiltEnvironmentType` enum.
|
||||
*/
|
||||
const QuiltEnvironmentTypeOptions: EnumOptions = {
|
||||
/**
|
||||
* Ignore the case of the environment type string when parsing.
|
||||
*/
|
||||
ignoreCase: true,
|
||||
|
||||
/**
|
||||
* Non-word characters should be ignored while parsing the filter.
|
||||
*/
|
||||
ignoreNonWordCharacters: true,
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents the different environments that a Quilt mod can run on.
|
||||
*/
|
||||
export const QuiltEnvironmentType = Enum.create(
|
||||
QuiltEnvironmentTypeValues,
|
||||
QuiltEnvironmentTypeOptions,
|
||||
);
|
||||
|
||||
/**
|
||||
* Represents the different environments that a Quilt mod can run on.
|
||||
*/
|
||||
export type QuiltEnvironmentType = Enum<typeof QuiltEnvironmentTypeValues>;
|
29
tests/unit/loaders/quilt/quilt-environment-type.spec.ts
Normal file
29
tests/unit/loaders/quilt/quilt-environment-type.spec.ts
Normal file
|
@ -0,0 +1,29 @@
|
|||
import { QuiltEnvironmentType } from "@/loaders/quilt/quilt-environment-type";
|
||||
|
||||
describe("QuiltEnvironmentType", () => {
|
||||
describe("parse", () => {
|
||||
test("parses all its own formatted values", () => {
|
||||
for (const value of QuiltEnvironmentType.values()) {
|
||||
expect(QuiltEnvironmentType.parse(QuiltEnvironmentType.format(value))).toBe(value);
|
||||
}
|
||||
});
|
||||
|
||||
test("parses all friendly names of its own values", () => {
|
||||
for (const value of QuiltEnvironmentType.values()) {
|
||||
expect(QuiltEnvironmentType.parse(QuiltEnvironmentType.friendlyNameOf(value))).toBe(value);
|
||||
}
|
||||
});
|
||||
|
||||
test("parses all its own formatted values in lowercase", () => {
|
||||
for (const value of QuiltEnvironmentType.values()) {
|
||||
expect(QuiltEnvironmentType.parse(QuiltEnvironmentType.format(value).toLowerCase())).toBe(value);
|
||||
}
|
||||
});
|
||||
|
||||
test("parses all its own formatted values in UPPERCASE", () => {
|
||||
for (const value of QuiltEnvironmentType.values()) {
|
||||
expect(QuiltEnvironmentType.parse(QuiltEnvironmentType.format(value).toUpperCase())).toBe(value);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue