Skip to content

Commit c8f2953

Browse files
committed
Add test for using boolean in enum
1 parent 708c2f7 commit c8f2953

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

tests/development/TestReactComponent.react.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ ReactComponent.propTypes = {
3737

3838
// You can ensure that your prop is limited to specific values by treating
3939
// it as an enum.
40-
optionalEnum: PropTypes.oneOf(['News', 'Photos', 1, 2]),
40+
optionalEnum: PropTypes.oneOf(['News', 'Photos', 1, 2, true, false]),
4141

4242
// An object that could be one of many types.
4343
optionalUnion: PropTypes.oneOfType([

tests/development/metadata_test.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@
101101
{
102102
"value": "2",
103103
"computed": false
104+
},
105+
{
106+
"value": "false",
107+
"computed": false
108+
},
109+
{
110+
"value": "true",
111+
"computed": false
104112
}
105113
]
106114
},

tests/development/test_component_validation.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,12 @@ def test_enum_validation(self):
313313
self.assertTrue(self.component_validator.validate({
314314
'optionalEnum': "1"
315315
}))
316+
self.assertTrue(self.component_validator.validate({
317+
'optionalEnum': True
318+
}))
319+
self.assertTrue(self.component_validator.validate({
320+
'optionalEnum': False
321+
}))
316322
self.assertFalse(self.component_validator.validate({
317323
'optionalEnum': "not_in_enum"
318324
}))

0 commit comments

Comments
 (0)