Skip to content

Commit e6498ac

Browse files
committed
Added unit tests for expected behaviors of this feature
- Allows simple type usage - Allows nested usage that uses 'shape' keyword - Allows usage inside of React shape
1 parent 75d5f1a commit e6498ac

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

tests/lib/rules/prop-types.js

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,87 @@ eslintTester.addRuleTest('lib/rules/prop-types', {
597597
classes: true,
598598
jsx: true
599599
}
600+
}, {
601+
code: [
602+
'var Hello = React.createClass({',
603+
' propTypes: {',
604+
' firstname: CustomValidator.string',
605+
' },',
606+
' render: function() {',
607+
' return <div>{this.props.firstname}</div>;',
608+
' }',
609+
'});'
610+
].join('\n'),
611+
args: [1, {customValidators: ['CustomValidator']}],
612+
ecmaFeatures: {
613+
jsx: true
614+
}
615+
}, {
616+
code: [
617+
'var Hello = React.createClass({',
618+
' propTypes: {',
619+
' outer: CustomValidator.shape({',
620+
' inner: CustomValidator.map',
621+
' })',
622+
' },',
623+
' render: function() {',
624+
' return <div>{this.props.outer.inner}</div>;',
625+
' }',
626+
'});'
627+
].join('\n'),
628+
args: [1, {customValidators: ['CustomValidator']}],
629+
ecmaFeatures: {
630+
jsx: true
631+
}
632+
}, {
633+
code: [
634+
'var Hello = React.createClass({',
635+
' propTypes: {',
636+
' outer: React.PropTypes.shape({',
637+
' inner: CustomValidator.string',
638+
' })',
639+
' },',
640+
' render: function() {',
641+
' return <div>{this.props.outer.inner}</div>;',
642+
' }',
643+
'});'
644+
].join('\n'),
645+
args: [1, {customValidators: ['CustomValidator']}],
646+
ecmaFeatures: {
647+
jsx: true
648+
}
649+
}, {
650+
code: [
651+
'var Hello = React.createClass({',
652+
' propTypes: {',
653+
' outer: CustomValidator.shape({',
654+
' inner: React.PropTypes.string',
655+
' })',
656+
' },',
657+
' render: function() {',
658+
' return <div>{this.props.outer.inner}</div>;',
659+
' }',
660+
'});'
661+
].join('\n'),
662+
args: [1, {customValidators: ['CustomValidator']}],
663+
ecmaFeatures: {
664+
jsx: true
665+
}
666+
}, {
667+
code: [
668+
'var Hello = React.createClass({',
669+
' propTypes: {',
670+
' name: React.PropTypes.string',
671+
' },',
672+
' render: function() {',
673+
' return <div>{this.props.name.get("test")}</div>;',
674+
' }',
675+
'});'
676+
].join('\n'),
677+
args: [1, {customValidators: ['CustomValidator']}],
678+
ecmaFeatures: {
679+
jsx: true
680+
}
600681
}
601682
],
602683

0 commit comments

Comments
 (0)