ts-enum-next 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +5 -5
- package/dist/index.js +20 -7
- package/dist/index.test.d.ts +1 -0
- package/dist/index.test.js +296 -0
- package/package.json +8 -3
package/dist/index.d.ts
CHANGED
|
@@ -14,11 +14,11 @@ declare abstract class Enum<T extends string | number = string | number> {
|
|
|
14
14
|
* @description 附加说明
|
|
15
15
|
*/
|
|
16
16
|
description?: unknown | undefined);
|
|
17
|
-
static values<T extends Enum>(): T[];
|
|
18
|
-
static fromValue<T extends Enum>(this: any, value: T['value']): T;
|
|
19
|
-
static fromName<T extends Enum>(this: any, name: string): T;
|
|
20
|
-
static setOf<T extends Enum>(this: any, ...items: T[]): Set<T>;
|
|
21
|
-
static enumMap<V>(this: any, map: Record<string | number, V>): Map<
|
|
17
|
+
static values<T extends Enum>(this: new (...args: any[]) => T): T[];
|
|
18
|
+
static fromValue<T extends Enum>(this: new (...args: any[]) => T, value: T['value']): T;
|
|
19
|
+
static fromName<T extends Enum>(this: new (...args: any[]) => T, name: string): T;
|
|
20
|
+
static setOf<T extends Enum>(this: new (...args: any[]) => T, ...items: T[]): Set<T>;
|
|
21
|
+
static enumMap<V, T extends Enum = Enum>(this: new (...args: any[]) => T, map: Record<string | number, V>): Map<T, V>;
|
|
22
22
|
toString(): string;
|
|
23
23
|
valueOf(): string;
|
|
24
24
|
}
|
package/dist/index.js
CHANGED
|
@@ -21,21 +21,21 @@ class Enum {
|
|
|
21
21
|
}
|
|
22
22
|
// 获取所有枚举值
|
|
23
23
|
static values() {
|
|
24
|
-
return
|
|
24
|
+
return Enum._values.get(this) || [];
|
|
25
25
|
}
|
|
26
26
|
// 通过值获取枚举实例
|
|
27
27
|
static fromValue(value) {
|
|
28
|
-
const enumInstance =
|
|
28
|
+
const enumInstance = Enum._valueMap.get(this)?.get(value);
|
|
29
29
|
if (!enumInstance) {
|
|
30
|
-
|
|
30
|
+
throw new Error(`No enum value ${value} found`);
|
|
31
31
|
}
|
|
32
32
|
return enumInstance;
|
|
33
33
|
}
|
|
34
34
|
// 通过名称获取枚举实例
|
|
35
35
|
static fromName(name) {
|
|
36
|
-
const enumInstance =
|
|
36
|
+
const enumInstance = Enum._nameMap.get(this)?.get(name);
|
|
37
37
|
if (!enumInstance) {
|
|
38
|
-
|
|
38
|
+
throw new Error(`No enum name ${name} found`);
|
|
39
39
|
}
|
|
40
40
|
return enumInstance;
|
|
41
41
|
}
|
|
@@ -47,8 +47,21 @@ class Enum {
|
|
|
47
47
|
static enumMap(map) {
|
|
48
48
|
const result = new Map();
|
|
49
49
|
for (const [key, value] of Object.entries(map)) {
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
// 判断 key 是否为纯数字字符串
|
|
51
|
+
const isNumericKey = /^\d+$/.test(key);
|
|
52
|
+
let enumKey;
|
|
53
|
+
try {
|
|
54
|
+
enumKey = isNumericKey
|
|
55
|
+
? this.fromValue(Number(key))
|
|
56
|
+
: this.fromName(key);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// 如果找不到对应的枚举值,跳过该键
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (enumKey) {
|
|
63
|
+
result.set(enumKey, value);
|
|
64
|
+
}
|
|
52
65
|
}
|
|
53
66
|
return result;
|
|
54
67
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { Enum } from './index';
|
|
3
|
+
// 定义测试用的枚举类
|
|
4
|
+
class HttpStatus extends Enum {
|
|
5
|
+
}
|
|
6
|
+
HttpStatus.OK = new HttpStatus(200, 'OK', 'Request succeeded');
|
|
7
|
+
HttpStatus.CREATED = new HttpStatus(201, 'CREATED', 'Resource created');
|
|
8
|
+
HttpStatus.BAD_REQUEST = new HttpStatus(400, 'BAD_REQUEST', 'Invalid request');
|
|
9
|
+
HttpStatus.NOT_FOUND = new HttpStatus(404, 'NOT_FOUND', 'Resource not found');
|
|
10
|
+
HttpStatus.SERVER_ERROR = new HttpStatus(500, 'SERVER_ERROR', 'Internal server error');
|
|
11
|
+
class OrderStatus extends Enum {
|
|
12
|
+
}
|
|
13
|
+
OrderStatus.PENDING = new OrderStatus('PENDING', 'Pending', 'Order is pending');
|
|
14
|
+
OrderStatus.PROCESSING = new OrderStatus('PROCESSING', 'Processing', 'Order is being processed');
|
|
15
|
+
OrderStatus.COMPLETED = new OrderStatus('COMPLETED', 'Completed', 'Order completed');
|
|
16
|
+
OrderStatus.CANCELLED = new OrderStatus('CANCELLED', 'Cancelled', 'Order cancelled');
|
|
17
|
+
class Priority extends Enum {
|
|
18
|
+
}
|
|
19
|
+
Priority.LOW = new Priority(1, 'LOW');
|
|
20
|
+
Priority.MEDIUM = new Priority(2, 'MEDIUM');
|
|
21
|
+
Priority.HIGH = new Priority(3, 'HIGH');
|
|
22
|
+
describe('Enum', () => {
|
|
23
|
+
describe('Constructor and basic properties', () => {
|
|
24
|
+
it('should create enum instance with value, name and description', () => {
|
|
25
|
+
expect(HttpStatus.OK.value).toBe(200);
|
|
26
|
+
expect(HttpStatus.OK.name).toBe('OK');
|
|
27
|
+
expect(HttpStatus.OK.description).toBe('Request succeeded');
|
|
28
|
+
});
|
|
29
|
+
it('should create enum instance without description', () => {
|
|
30
|
+
expect(Priority.LOW.value).toBe(1);
|
|
31
|
+
expect(Priority.LOW.name).toBe('LOW');
|
|
32
|
+
expect(Priority.LOW.description).toBeUndefined();
|
|
33
|
+
});
|
|
34
|
+
it('should support string value enums', () => {
|
|
35
|
+
expect(OrderStatus.PENDING.value).toBe('PENDING');
|
|
36
|
+
expect(OrderStatus.PENDING.name).toBe('Pending');
|
|
37
|
+
expect(OrderStatus.PENDING.description).toBe('Order is pending');
|
|
38
|
+
});
|
|
39
|
+
it('should support number value enums', () => {
|
|
40
|
+
expect(HttpStatus.NOT_FOUND.value).toBe(404);
|
|
41
|
+
expect(HttpStatus.NOT_FOUND.name).toBe('NOT_FOUND');
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
describe('values()', () => {
|
|
45
|
+
it('should return all enum values for HttpStatus', () => {
|
|
46
|
+
const values = HttpStatus.values();
|
|
47
|
+
expect(values).toHaveLength(5);
|
|
48
|
+
expect(values).toContain(HttpStatus.OK);
|
|
49
|
+
expect(values).toContain(HttpStatus.CREATED);
|
|
50
|
+
expect(values).toContain(HttpStatus.BAD_REQUEST);
|
|
51
|
+
expect(values).toContain(HttpStatus.NOT_FOUND);
|
|
52
|
+
expect(values).toContain(HttpStatus.SERVER_ERROR);
|
|
53
|
+
});
|
|
54
|
+
it('should return all enum values for OrderStatus', () => {
|
|
55
|
+
const values = OrderStatus.values();
|
|
56
|
+
expect(values).toHaveLength(4);
|
|
57
|
+
expect(values).toContain(OrderStatus.PENDING);
|
|
58
|
+
expect(values).toContain(OrderStatus.PROCESSING);
|
|
59
|
+
expect(values).toContain(OrderStatus.COMPLETED);
|
|
60
|
+
expect(values).toContain(OrderStatus.CANCELLED);
|
|
61
|
+
});
|
|
62
|
+
it('should return all enum values for Priority', () => {
|
|
63
|
+
const values = Priority.values();
|
|
64
|
+
expect(values).toHaveLength(3);
|
|
65
|
+
expect(values).toContain(Priority.LOW);
|
|
66
|
+
expect(values).toContain(Priority.MEDIUM);
|
|
67
|
+
expect(values).toContain(Priority.HIGH);
|
|
68
|
+
});
|
|
69
|
+
it('should not share values between different enum classes', () => {
|
|
70
|
+
const httpValues = HttpStatus.values();
|
|
71
|
+
const orderValues = OrderStatus.values();
|
|
72
|
+
expect(httpValues).not.toEqual(orderValues);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
describe('fromValue()', () => {
|
|
76
|
+
it('should find enum by numeric value', () => {
|
|
77
|
+
const status = HttpStatus.fromValue(200);
|
|
78
|
+
expect(status).toBe(HttpStatus.OK);
|
|
79
|
+
expect(status.name).toBe('OK');
|
|
80
|
+
});
|
|
81
|
+
it('should find enum by string value', () => {
|
|
82
|
+
const status = OrderStatus.fromValue('PENDING');
|
|
83
|
+
expect(status).toBe(OrderStatus.PENDING);
|
|
84
|
+
expect(status.name).toBe('Pending');
|
|
85
|
+
});
|
|
86
|
+
it('should find different enum instances by different values', () => {
|
|
87
|
+
expect(HttpStatus.fromValue(200)).toBe(HttpStatus.OK);
|
|
88
|
+
expect(HttpStatus.fromValue(404)).toBe(HttpStatus.NOT_FOUND);
|
|
89
|
+
expect(HttpStatus.fromValue(500)).toBe(HttpStatus.SERVER_ERROR);
|
|
90
|
+
});
|
|
91
|
+
it('should throw error for non-existent numeric value', () => {
|
|
92
|
+
expect(() => HttpStatus.fromValue(999)).toThrow('No enum value 999 found');
|
|
93
|
+
});
|
|
94
|
+
it('should throw error for non-existent string value', () => {
|
|
95
|
+
expect(() => OrderStatus.fromValue('INVALID')).toThrow('No enum value INVALID found');
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
describe('fromName()', () => {
|
|
99
|
+
it('should find enum by name', () => {
|
|
100
|
+
const status = HttpStatus.fromName('OK');
|
|
101
|
+
expect(status).toBe(HttpStatus.OK);
|
|
102
|
+
expect(status.value).toBe(200);
|
|
103
|
+
});
|
|
104
|
+
it('should find enum by name for string value enum', () => {
|
|
105
|
+
const status = OrderStatus.fromName('Pending');
|
|
106
|
+
expect(status).toBe(OrderStatus.PENDING);
|
|
107
|
+
expect(status.value).toBe('PENDING');
|
|
108
|
+
});
|
|
109
|
+
it('should find different enum instances by different names', () => {
|
|
110
|
+
expect(HttpStatus.fromName('OK')).toBe(HttpStatus.OK);
|
|
111
|
+
expect(HttpStatus.fromName('NOT_FOUND')).toBe(HttpStatus.NOT_FOUND);
|
|
112
|
+
expect(HttpStatus.fromName('SERVER_ERROR')).toBe(HttpStatus.SERVER_ERROR);
|
|
113
|
+
});
|
|
114
|
+
it('should throw error for non-existent name', () => {
|
|
115
|
+
expect(() => HttpStatus.fromName('INVALID')).toThrow('No enum name INVALID found');
|
|
116
|
+
});
|
|
117
|
+
it('should be case-sensitive', () => {
|
|
118
|
+
expect(() => HttpStatus.fromName('ok')).toThrow('No enum name ok found');
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
describe('setOf()', () => {
|
|
122
|
+
it('should create a Set containing specified enum values', () => {
|
|
123
|
+
const errorStatuses = HttpStatus.setOf(HttpStatus.BAD_REQUEST, HttpStatus.NOT_FOUND, HttpStatus.SERVER_ERROR);
|
|
124
|
+
expect(errorStatuses.size).toBe(3);
|
|
125
|
+
expect(errorStatuses.has(HttpStatus.BAD_REQUEST)).toBe(true);
|
|
126
|
+
expect(errorStatuses.has(HttpStatus.NOT_FOUND)).toBe(true);
|
|
127
|
+
expect(errorStatuses.has(HttpStatus.SERVER_ERROR)).toBe(true);
|
|
128
|
+
expect(errorStatuses.has(HttpStatus.OK)).toBe(false);
|
|
129
|
+
});
|
|
130
|
+
it('should create empty Set when no arguments provided', () => {
|
|
131
|
+
const emptySet = HttpStatus.setOf();
|
|
132
|
+
expect(emptySet.size).toBe(0);
|
|
133
|
+
});
|
|
134
|
+
it('should handle duplicate values', () => {
|
|
135
|
+
const set = HttpStatus.setOf(HttpStatus.OK, HttpStatus.OK, HttpStatus.NOT_FOUND);
|
|
136
|
+
expect(set.size).toBe(2);
|
|
137
|
+
});
|
|
138
|
+
it('should work with string value enums', () => {
|
|
139
|
+
const activeStatuses = OrderStatus.setOf(OrderStatus.PENDING, OrderStatus.PROCESSING);
|
|
140
|
+
expect(activeStatuses.size).toBe(2);
|
|
141
|
+
expect(activeStatuses.has(OrderStatus.PENDING)).toBe(true);
|
|
142
|
+
expect(activeStatuses.has(OrderStatus.PROCESSING)).toBe(true);
|
|
143
|
+
expect(activeStatuses.has(OrderStatus.COMPLETED)).toBe(false);
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
describe('enumMap()', () => {
|
|
147
|
+
it('should create map using numeric value as key', () => {
|
|
148
|
+
const statusMessages = HttpStatus.enumMap({
|
|
149
|
+
200: 'Success',
|
|
150
|
+
404: 'Not Found',
|
|
151
|
+
500: 'Error'
|
|
152
|
+
});
|
|
153
|
+
expect(statusMessages.size).toBe(3);
|
|
154
|
+
expect(statusMessages.get(HttpStatus.OK)).toBe('Success');
|
|
155
|
+
expect(statusMessages.get(HttpStatus.NOT_FOUND)).toBe('Not Found');
|
|
156
|
+
expect(statusMessages.get(HttpStatus.SERVER_ERROR)).toBe('Error');
|
|
157
|
+
});
|
|
158
|
+
it('should create map using name as key', () => {
|
|
159
|
+
const statusMessages = HttpStatus.enumMap({
|
|
160
|
+
OK: 'Operation successful',
|
|
161
|
+
NOT_FOUND: 'Resource does not exist'
|
|
162
|
+
});
|
|
163
|
+
expect(statusMessages.size).toBe(2);
|
|
164
|
+
expect(statusMessages.get(HttpStatus.OK)).toBe('Operation successful');
|
|
165
|
+
expect(statusMessages.get(HttpStatus.NOT_FOUND)).toBe('Resource does not exist');
|
|
166
|
+
});
|
|
167
|
+
it('should create map mixing numeric and name keys', () => {
|
|
168
|
+
const statusMessages = HttpStatus.enumMap({
|
|
169
|
+
200: 'Success',
|
|
170
|
+
NOT_FOUND: 'Resource does not exist',
|
|
171
|
+
500: 'Error'
|
|
172
|
+
});
|
|
173
|
+
expect(statusMessages.size).toBe(3);
|
|
174
|
+
expect(statusMessages.get(HttpStatus.OK)).toBe('Success');
|
|
175
|
+
expect(statusMessages.get(HttpStatus.NOT_FOUND)).toBe('Resource does not exist');
|
|
176
|
+
expect(statusMessages.get(HttpStatus.SERVER_ERROR)).toBe('Error');
|
|
177
|
+
});
|
|
178
|
+
it('should skip invalid keys silently', () => {
|
|
179
|
+
const statusMessages = HttpStatus.enumMap({
|
|
180
|
+
200: 'Success',
|
|
181
|
+
999: 'Invalid',
|
|
182
|
+
INVALID_NAME: 'Also Invalid'
|
|
183
|
+
});
|
|
184
|
+
expect(statusMessages.size).toBe(1);
|
|
185
|
+
expect(statusMessages.get(HttpStatus.OK)).toBe('Success');
|
|
186
|
+
});
|
|
187
|
+
it('should work with string value enums', () => {
|
|
188
|
+
const orderMessages = OrderStatus.enumMap({
|
|
189
|
+
Pending: 'Waiting for payment',
|
|
190
|
+
Completed: 'Order finished'
|
|
191
|
+
});
|
|
192
|
+
expect(orderMessages.size).toBe(2);
|
|
193
|
+
expect(orderMessages.get(OrderStatus.PENDING)).toBe('Waiting for payment');
|
|
194
|
+
expect(orderMessages.get(OrderStatus.COMPLETED)).toBe('Order finished');
|
|
195
|
+
});
|
|
196
|
+
it('should create empty map for empty input', () => {
|
|
197
|
+
const emptyMap = HttpStatus.enumMap({});
|
|
198
|
+
expect(emptyMap.size).toBe(0);
|
|
199
|
+
});
|
|
200
|
+
it('should handle complex value types', () => {
|
|
201
|
+
const statusConfig = HttpStatus.enumMap({
|
|
202
|
+
200: { color: 'green', icon: 'check' },
|
|
203
|
+
400: { color: 'orange', icon: 'warning' },
|
|
204
|
+
NOT_FOUND: { color: 'red', icon: 'error' }
|
|
205
|
+
});
|
|
206
|
+
expect(statusConfig.get(HttpStatus.OK)).toEqual({ color: 'green', icon: 'check' });
|
|
207
|
+
expect(statusConfig.get(HttpStatus.BAD_REQUEST)).toEqual({ color: 'orange', icon: 'warning' });
|
|
208
|
+
expect(statusConfig.get(HttpStatus.NOT_FOUND)).toEqual({ color: 'red', icon: 'error' });
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
describe('toString()', () => {
|
|
212
|
+
it('should return the name', () => {
|
|
213
|
+
expect(HttpStatus.OK.toString()).toBe('OK');
|
|
214
|
+
expect(OrderStatus.PENDING.toString()).toBe('Pending');
|
|
215
|
+
});
|
|
216
|
+
it('should work with string concatenation', () => {
|
|
217
|
+
// valueOf() is called during string concatenation, which returns the value
|
|
218
|
+
const messageWithValue = 'Status: ' + HttpStatus.OK;
|
|
219
|
+
expect(messageWithValue).toBe('Status: 200');
|
|
220
|
+
// Use toString() explicitly to get the name
|
|
221
|
+
const messageWithName = 'Status: ' + HttpStatus.OK.toString();
|
|
222
|
+
expect(messageWithName).toBe('Status: OK');
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
describe('valueOf()', () => {
|
|
226
|
+
it('should return string representation of numeric value', () => {
|
|
227
|
+
expect(HttpStatus.OK.valueOf()).toBe('200');
|
|
228
|
+
expect(HttpStatus.NOT_FOUND.valueOf()).toBe('404');
|
|
229
|
+
});
|
|
230
|
+
it('should return string value for string enum', () => {
|
|
231
|
+
expect(OrderStatus.PENDING.valueOf()).toBe('PENDING');
|
|
232
|
+
expect(OrderStatus.COMPLETED.valueOf()).toBe('COMPLETED');
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
describe('Multiple enum classes isolation', () => {
|
|
236
|
+
it('should maintain separate instances for different enum classes', () => {
|
|
237
|
+
expect(HttpStatus.values().length).toBe(5);
|
|
238
|
+
expect(OrderStatus.values().length).toBe(4);
|
|
239
|
+
expect(Priority.values().length).toBe(3);
|
|
240
|
+
});
|
|
241
|
+
it('should not interfere with each other when querying by value', () => {
|
|
242
|
+
// 虽然值相同,但是不同的枚举类
|
|
243
|
+
expect(() => HttpStatus.fromValue('PENDING')).toThrow();
|
|
244
|
+
expect(() => OrderStatus.fromValue(200)).toThrow();
|
|
245
|
+
});
|
|
246
|
+
it('should not interfere with each other when querying by name', () => {
|
|
247
|
+
expect(() => HttpStatus.fromName('Pending')).toThrow();
|
|
248
|
+
expect(() => OrderStatus.fromName('OK')).toThrow();
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
describe('Edge cases', () => {
|
|
252
|
+
it('should handle enum with same value but different names', () => {
|
|
253
|
+
class DuplicateValueEnum extends Enum {
|
|
254
|
+
}
|
|
255
|
+
DuplicateValueEnum.FIRST = new DuplicateValueEnum(1, 'FIRST');
|
|
256
|
+
DuplicateValueEnum.SECOND = new DuplicateValueEnum(1, 'SECOND');
|
|
257
|
+
// 最后一个定义的会覆盖前面的(Map 的行为)
|
|
258
|
+
const found = DuplicateValueEnum.fromValue(1);
|
|
259
|
+
expect(found.name).toBe('SECOND');
|
|
260
|
+
});
|
|
261
|
+
it('should handle description as different types', () => {
|
|
262
|
+
class MixedDescEnum extends Enum {
|
|
263
|
+
}
|
|
264
|
+
MixedDescEnum.STRING_DESC = new MixedDescEnum(1, 'STRING', 'string description');
|
|
265
|
+
MixedDescEnum.NUMBER_DESC = new MixedDescEnum(2, 'NUMBER', 42);
|
|
266
|
+
MixedDescEnum.OBJECT_DESC = new MixedDescEnum(3, 'OBJECT', { key: 'value' });
|
|
267
|
+
MixedDescEnum.ARRAY_DESC = new MixedDescEnum(4, 'ARRAY', ['a', 'b']);
|
|
268
|
+
expect(MixedDescEnum.STRING_DESC.description).toBe('string description');
|
|
269
|
+
expect(MixedDescEnum.NUMBER_DESC.description).toBe(42);
|
|
270
|
+
expect(MixedDescEnum.OBJECT_DESC.description).toEqual({ key: 'value' });
|
|
271
|
+
expect(MixedDescEnum.ARRAY_DESC.description).toEqual(['a', 'b']);
|
|
272
|
+
});
|
|
273
|
+
it('should work with zero and empty string values', () => {
|
|
274
|
+
class EdgeValueEnum extends Enum {
|
|
275
|
+
}
|
|
276
|
+
EdgeValueEnum.ZERO = new EdgeValueEnum(0, 'ZERO');
|
|
277
|
+
EdgeValueEnum.EMPTY = new EdgeValueEnum('', 'EMPTY');
|
|
278
|
+
expect(EdgeValueEnum.fromValue(0)).toBe(EdgeValueEnum.ZERO);
|
|
279
|
+
expect(EdgeValueEnum.fromValue('')).toBe(EdgeValueEnum.EMPTY);
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
describe('Type exports', () => {
|
|
283
|
+
it('should have correct EnumValueType', () => {
|
|
284
|
+
const numValue = 123;
|
|
285
|
+
const strValue = 'test';
|
|
286
|
+
expect(typeof numValue).toBe('number');
|
|
287
|
+
expect(typeof strValue).toBe('string');
|
|
288
|
+
});
|
|
289
|
+
it('should extract enum values with EnumValues type', () => {
|
|
290
|
+
const value1 = 200;
|
|
291
|
+
const value2 = 404;
|
|
292
|
+
expect(value1).toBe(200);
|
|
293
|
+
expect(value2).toBe(404);
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
});
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-enum-next",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Ultimate Enum Enhancement for TypeScript",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc",
|
|
9
|
+
"test": "vitest run",
|
|
10
|
+
"test:watch": "vitest",
|
|
11
|
+
"test:coverage": "vitest run --coverage",
|
|
9
12
|
"prepublishOnly": "pnpm run build"
|
|
10
13
|
},
|
|
11
14
|
"keywords": [
|
|
@@ -24,7 +27,7 @@
|
|
|
24
27
|
"homepage": "https://github.com/ricoNext/ts-enum-next",
|
|
25
28
|
"repository": {
|
|
26
29
|
"type": "git",
|
|
27
|
-
"url": "https://github.com/ricoNext/ts-enum-next.git"
|
|
30
|
+
"url": "git+https://github.com/ricoNext/ts-enum-next.git"
|
|
28
31
|
},
|
|
29
32
|
"authors": {
|
|
30
33
|
"name": "ricoNext",
|
|
@@ -32,6 +35,8 @@
|
|
|
32
35
|
},
|
|
33
36
|
"license": "ISC",
|
|
34
37
|
"devDependencies": {
|
|
35
|
-
"
|
|
38
|
+
"@vitest/coverage-v8": "^4.0.16",
|
|
39
|
+
"typescript": "^5.8.3",
|
|
40
|
+
"vitest": "^4.0.16"
|
|
36
41
|
}
|
|
37
42
|
}
|