Skip to content

Commit

Permalink
Add test cases for function components
Browse files Browse the repository at this point in the history
  • Loading branch information
Joachim Seminck committed Jun 28, 2017
1 parent 394b4d5 commit 5ac830e
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions tests/lib/rules/no-static-typos.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,15 @@ ruleTester.run('no-static-typos', rule, {
'MyClass.DefaultProps = function() {};'
].join('\n'),
parserOptions: parserOptions
}, {
code: [
'function MyRandomFunction() {}',
'MyRandomFunction.PropTypes = {};',
'MyRandomFunction.ContextTypes = {};',
'MyRandomFunction.ChildContextTypes = {};',
'MyRandomFunction.DefaultProps = {};'
].join('\n'),
parserOptions: parserOptions
}],

invalid: [{
Expand All @@ -158,6 +167,13 @@ ruleTester.run('no-static-typos', rule, {
].join('\n'),
parserOptions: parserOptions,
errors: [{message: ERROR_MESSAGE}]
}, {
code: [
'function MyComponent() { return (<div>{this.props.myProp</div>) }',
'MyComponent.PropTypes = {}'
].join('\n'),
parserOptions: parserOptions,
errors: [{message: ERROR_MESSAGE}]
}, {
code: [
'class Component extends React.Component {',
Expand All @@ -174,6 +190,13 @@ ruleTester.run('no-static-typos', rule, {
].join('\n'),
parserOptions: parserOptions,
errors: [{message: ERROR_MESSAGE}]
}, {
code: [
'function MyComponent() { return (<div>{this.props.myProp</div>) }',
'MyComponent.proptypes = {}'
].join('\n'),
parserOptions: parserOptions,
errors: [{message: ERROR_MESSAGE}]
}, {
code: [
'class Component extends React.Component {',
Expand All @@ -190,6 +213,13 @@ ruleTester.run('no-static-typos', rule, {
].join('\n'),
parserOptions: parserOptions,
errors: [{message: ERROR_MESSAGE}]
}, {
code: [
'function MyComponent() { return (<div>{this.props.myProp</div>) }',
'MyComponent.ContextTypes = {}'
].join('\n'),
parserOptions: parserOptions,
errors: [{message: ERROR_MESSAGE}]
}, {
code: [
'class Component extends React.Component {',
Expand All @@ -206,6 +236,13 @@ ruleTester.run('no-static-typos', rule, {
].join('\n'),
parserOptions: parserOptions,
errors: [{message: ERROR_MESSAGE}]
}, {
code: [
'function MyComponent() { return (<div>{this.props.myProp</div>) }',
'MyComponent.contexttypes = {}'
].join('\n'),
parserOptions: parserOptions,
errors: [{message: ERROR_MESSAGE}]
}, {
code: [
'class Component extends React.Component {',
Expand All @@ -222,6 +259,13 @@ ruleTester.run('no-static-typos', rule, {
].join('\n'),
parserOptions: parserOptions,
errors: [{message: ERROR_MESSAGE}]
}, {
code: [
'function MyComponent() { return (<div>{this.props.myProp</div>) }',
'MyComponent.ChildContextTypes = {}'
].join('\n'),
parserOptions: parserOptions,
errors: [{message: ERROR_MESSAGE}]
}, {
code: [
'class Component extends React.Component {',
Expand All @@ -238,6 +282,13 @@ ruleTester.run('no-static-typos', rule, {
].join('\n'),
parserOptions: parserOptions,
errors: [{message: ERROR_MESSAGE}]
}, {
code: [
'function MyComponent() { return (<div>{this.props.myProp</div>) }',
'MyComponent.childcontexttypes = {}'
].join('\n'),
parserOptions: parserOptions,
errors: [{message: ERROR_MESSAGE}]
}, {
code: [
'class Component extends React.Component {',
Expand All @@ -254,6 +305,13 @@ ruleTester.run('no-static-typos', rule, {
].join('\n'),
parserOptions: parserOptions,
errors: [{message: ERROR_MESSAGE}]
}, {
code: [
'function MyComponent() { return (<div>{this.props.myProp</div>) }',
'MyComponent.DefaultProps = {}'
].join('\n'),
parserOptions: parserOptions,
errors: [{message: ERROR_MESSAGE}]
}, {
code: [
'class Component extends React.Component {',
Expand All @@ -270,5 +328,12 @@ ruleTester.run('no-static-typos', rule, {
].join('\n'),
parserOptions: parserOptions,
errors: [{message: ERROR_MESSAGE}]
}, {
code: [
'function MyComponent() { return (<div>{this.props.myProp</div>) }',
'MyComponent.defaultprops = {}'
].join('\n'),
parserOptions: parserOptions,
errors: [{message: ERROR_MESSAGE}]
}]
});

0 comments on commit 5ac830e

Please sign in to comment.