diff --git a/src/valueRules/enum/enum.test.ts b/src/valueRules/enum/enum.test.ts index 7a2877e46..395434d84 100644 --- a/src/valueRules/enum/enum.test.ts +++ b/src/valueRules/enum/enum.test.ts @@ -5,6 +5,10 @@ enum TestEnum { TestValue, } +enum TestNamedEnum { + TestValue = 'TestValue', +} + test('enum should allow enum value', () => { const input = TestEnum.TestValue const output: TestEnum = enumerated(TestEnum)(input) @@ -14,3 +18,13 @@ test('enum should allow enum value', () => { test('enum should not allow non-enum value', () => { assert.throws(() => enumerated(TestEnum)('NonEnumValue'), InvalidEnumError) }) + +test('enum should allow named enum value', () => { + const input = TestNamedEnum.TestValue + const output: TestNamedEnum = enumerated(TestNamedEnum)(input) + assert.strictEqual(output, input) +}) + +test('enum should not allow named non-enum value', () => { + assert.throws(() => enumerated(TestNamedEnum)('NonEnumValue'), InvalidEnumError) +})