Skip to content

Commit 28b685e

Browse files
committed
Add missing test coverage
1 parent e35e97d commit 28b685e

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

test/exclude.test.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,46 @@ describe('Enum.exclude', () => {
7272
expect(ERROR_LEVEL.keyOf(1)).toBe('warn');
7373
});
7474
});
75+
76+
describe('labeled enum - remove by value', () => {
77+
const LEVEL = Enum({ off: 0, warn: 1, error: 2 });
78+
const ERROR_LEVEL = Enum.exclude(LEVEL, [0]);
79+
type ErrorLevel = InferValue<typeof ERROR_LEVEL>;
80+
81+
test('values', () => {
82+
expect(ERROR_LEVEL.values()).toEqual([1, 2]);
83+
});
84+
85+
test('hasValue', () => {
86+
expect(ERROR_LEVEL.hasValue(0)).toBe(false);
87+
expect(ERROR_LEVEL.hasValue(1)).toBe(true);
88+
});
89+
90+
test('keys', () => {
91+
expect(ERROR_LEVEL.keys()).toEqual(['warn', 'error']);
92+
});
93+
94+
test('hasKey', () => {
95+
expect(ERROR_LEVEL.hasKey('off')).toBe(false);
96+
expect(ERROR_LEVEL.hasKey('error')).toBe(true);
97+
});
98+
99+
test('entries', () => {
100+
expect(ERROR_LEVEL.entries()).toEqual([
101+
['warn', 1],
102+
['error', 2],
103+
]);
104+
});
105+
106+
test('object', () => {
107+
expect(ERROR_LEVEL.object).toEqual<(typeof ERROR_LEVEL)['object']>({
108+
warn: 1,
109+
error: 2,
110+
});
111+
});
112+
113+
test('keyOf', () => {
114+
expect(ERROR_LEVEL.keyOf(1)).toBe('warn');
115+
});
116+
});
75117
});

0 commit comments

Comments
 (0)