Skip to content

Commit

Permalink
[jsx-sort-props] Test reservedFirst/shorthandLast
Browse files Browse the repository at this point in the history
Add tests, that surface the incorrect behavior of the combinations
`reservedFirst` and `shorthandLast` for the `jsx-sort-props` rule.
  • Loading branch information
fleischie committed Jul 13, 2018
1 parent b1f2b6f commit 049d95e
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion tests/lib/rules/jsx-sort-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ const reservedFirstWithNoSortAlphabeticallyArgs = [{
noSortAlphabetically: true,
reservedFirst: true
}];
const reservedFirstWithShorthandLast = [{
reservedFirst: true,
shorthandLast: true
}];
const reservedFirstAsEmptyArrayArgs = [{
reservedFirst: []
}];
Expand Down Expand Up @@ -149,6 +153,10 @@ ruleTester.run('jsx-sort-props', rule, {
{
code: '<div ref="r" dangerouslySetInnerHTML={{__html: "EPR"}} key={0} children={<App />} b a c />',
options: reservedFirstWithNoSortAlphabeticallyArgs
},
{
code: '<App key="key" c="c" b />',
options: reservedFirstWithShorthandLast
}
],
invalid: [
Expand Down Expand Up @@ -230,6 +238,16 @@ ruleTester.run('jsx-sort-props', rule, {
`,
errors: 3
},
{
code: '<App key="key" b c="c" />',
errors: [expectedShorthandLastError],
options: reservedFirstWithShorthandLast
},
{
code: '<App ref="ref" key="key" isShorthand veryLastAttribute="yes" />',
errors: [expectedError, expectedShorthandLastError],
options: reservedFirstWithShorthandLast
},
{
code: '<App a z onFoo onBar />;',
errors: [expectedError],
Expand Down Expand Up @@ -293,7 +311,7 @@ ruleTester.run('jsx-sort-props', rule, {
code: '<App dangerouslySetInnerHTML={{__html: "EPR"}} e key={2} b />',
options: reservedFirstAsBooleanArgs,
output: '<App key={2} b dangerouslySetInnerHTML={{__html: "EPR"}} e />',
errors: [expectedReservedFirstError]
errors: [expectedReservedFirstError, expectedError]
},
{
code: '<App key={3} children={<App />} />',
Expand Down

0 comments on commit 049d95e

Please sign in to comment.