-
Notifications
You must be signed in to change notification settings - Fork 808
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fail for non-array constraint in
@IsIn
decorator (#1844)
- Loading branch information
1 parent
0c30684
commit 2b60e0e
Showing
2 changed files
with
18 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { isIn } from './IsIn'; | ||
|
||
describe('@IsIn decorator implementation', () => { | ||
describe('isIn validator', () => { | ||
it('should accept valid values', () => { | ||
expect(isIn('A', ['A', 'B'])).toBe(true); | ||
expect(isIn('A', ['B', 'C'])).toBe(false); | ||
expect(isIn('A', [1, 2])).toBe(false); | ||
}); | ||
|
||
it('should not accept invalid values', () => { | ||
expect(isIn('A', 5 as any)).toBe(false); | ||
expect(isIn('A', 'ABC' as any)).toBe(false); | ||
expect(isIn('A', false as any)).toBe(false); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters