Skip to content

Commit

Permalink
Add tests for async functions and generators
Browse files Browse the repository at this point in the history
  • Loading branch information
alexzherdev committed Jul 27, 2018
1 parent a8702ce commit 9fda347
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tests/lib/rules/no-children-prop.js
Expand Up @@ -155,6 +155,18 @@ ruleTester.run('no-children-prop', rule, {
allowFunctions: true
}]
},
{
code: '<MyComponent children={async function() {}} />;',
options: [{
allowFunctions: true
}]
},
{
code: '<MyComponent children={function* () {}} />;',
options: [{
allowFunctions: true
}]
},
{
code: 'React.createElement(MyComponent, {children: () => {}});',
options: [{
Expand All @@ -166,6 +178,18 @@ ruleTester.run('no-children-prop', rule, {
options: [{
allowFunctions: true
}]
},
{
code: 'React.createElement(MyComponent, {children: async function() {}});',
options: [{
allowFunctions: true
}]
},
{
code: 'React.createElement(MyComponent, {children: function* () {}});',
options: [{
allowFunctions: true
}]
}
],
invalid: [
Expand Down Expand Up @@ -243,6 +267,20 @@ ruleTester.run('no-children-prop', rule, {
}],
errors: [{message: JSX_FUNCTION_ERROR}]
},
{
code: '<MyComponent>{async function() {}}</MyComponent>;',
options: [{
allowFunctions: true
}],
errors: [{message: JSX_FUNCTION_ERROR}]
},
{
code: '<MyComponent>{function* () {}}</MyComponent>;',
options: [{
allowFunctions: true
}],
errors: [{message: JSX_FUNCTION_ERROR}]
},
{
code: 'React.createElement(MyComponent, {}, () => {});',
options: [{
Expand All @@ -256,6 +294,20 @@ ruleTester.run('no-children-prop', rule, {
allowFunctions: true
}],
errors: [{message: CREATE_ELEMENT_FUNCTION_ERROR}]
},
{
code: 'React.createElement(MyComponent, {}, async function() {});',
options: [{
allowFunctions: true
}],
errors: [{message: CREATE_ELEMENT_FUNCTION_ERROR}]
},
{
code: 'React.createElement(MyComponent, {}, function* () {});',
options: [{
allowFunctions: true
}],
errors: [{message: CREATE_ELEMENT_FUNCTION_ERROR}]
}
]
});

0 comments on commit 9fda347

Please sign in to comment.