Skip to content

Commit

Permalink
test: Adds test for named enums
Browse files Browse the repository at this point in the history
  • Loading branch information
ryasmi committed Dec 17, 2024
1 parent 342c49e commit 1bef9c3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/valueRules/enum/enum.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
})

0 comments on commit 1bef9c3

Please sign in to comment.