mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-11-22 08:20:58 -05:00
Made DependencyType
enum
This commit is contained in:
parent
a7049ca420
commit
989ccf0c87
2 changed files with 92 additions and 0 deletions
63
src/dependencies/dependency-type.ts
Normal file
63
src/dependencies/dependency-type.ts
Normal file
|
@ -0,0 +1,63 @@
|
|||
import { Enum, EnumOptions } from "@/utils/enum";
|
||||
|
||||
/**
|
||||
* Represents different dependency types.
|
||||
*
|
||||
* @partial
|
||||
*/
|
||||
enum DependencyTypeValues {
|
||||
/**
|
||||
* The dependency is required for the project to function.
|
||||
*/
|
||||
REQUIRED = "required",
|
||||
|
||||
/**
|
||||
* The dependency is recommended for the project but not required.
|
||||
*/
|
||||
RECOMMENDED = "recommended",
|
||||
|
||||
/**
|
||||
* The dependency is embedded within the project.
|
||||
*/
|
||||
EMBEDDED = "embedded",
|
||||
|
||||
/**
|
||||
* The dependency is optional and provides additional features.
|
||||
*/
|
||||
OPTIONAL = "optional",
|
||||
|
||||
/**
|
||||
* The dependency conflicts with the project and both should not be used together.
|
||||
*/
|
||||
CONFLICTING = "conflicting",
|
||||
|
||||
/**
|
||||
* The dependency is incompatible with the project.
|
||||
*/
|
||||
INCOMPATIBLE = "incompatible",
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for configuring the behavior of the DependencyType enum.
|
||||
*
|
||||
* @partial
|
||||
*/
|
||||
const DependencyTypeOptions: EnumOptions = {
|
||||
/**
|
||||
* The case should be ignored while parsing the dependency type.
|
||||
*/
|
||||
ignoreCase: true,
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents different dependency types.
|
||||
*/
|
||||
export const DependencyType = Enum.create(
|
||||
DependencyTypeValues,
|
||||
DependencyTypeOptions,
|
||||
);
|
||||
|
||||
/**
|
||||
* Represents different dependency types.
|
||||
*/
|
||||
export type DependencyType = Enum<typeof DependencyTypeValues>;
|
29
tests/unit/dependencies/dependency-type.spec.ts
Normal file
29
tests/unit/dependencies/dependency-type.spec.ts
Normal file
|
@ -0,0 +1,29 @@
|
|||
import { DependencyType } from "@/dependencies/dependency-type";
|
||||
|
||||
describe("DependencyType", () => {
|
||||
describe("parse", () => {
|
||||
test("parses all its own formatted values", () => {
|
||||
for (const value of DependencyType.values()) {
|
||||
expect(DependencyType.parse(DependencyType.format(value))).toBe(value);
|
||||
}
|
||||
});
|
||||
|
||||
test("parses all friendly names of its own values", () => {
|
||||
for (const value of DependencyType.values()) {
|
||||
expect(DependencyType.parse(DependencyType.friendlyNameOf(value))).toBe(value);
|
||||
}
|
||||
});
|
||||
|
||||
test("parses all its own formatted values in lowercase", () => {
|
||||
for (const value of DependencyType.values()) {
|
||||
expect(DependencyType.parse(DependencyType.format(value).toLowerCase())).toBe(value);
|
||||
}
|
||||
});
|
||||
|
||||
test("parses all its own formatted values in UPPERCASE", () => {
|
||||
for (const value of DependencyType.values()) {
|
||||
expect(DependencyType.parse(DependencyType.format(value).toUpperCase())).toBe(value);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue