Skip to content

Commit

Permalink
Add tests around the functionality of a parser without start/end values.
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Eckhoff committed Oct 24, 2018
1 parent aa4c339 commit a7cbf40
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 1 deletion.
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -37,7 +37,9 @@
"coveralls": "^3.0.1",
"eslint": "^3.0.0 || ^4.0.0 || ^5.0.0",
"istanbul": "^0.4.5",
"mocha": "^5.2.0"
"mocha": "^5.2.0",
"typescript": "^3.1.3",
"typescript-eslint-parser": "^20.0.0"
},
"peerDependencies": {
"eslint": "^3.0.0 || ^4.0.0 || ^5.0.0"
Expand Down
81 changes: 81 additions & 0 deletions tests/lib/rules/jsx-first-prop-new-line.js
Expand Up @@ -129,6 +129,17 @@ ruleTester.run('jsx-first-prop-new-line', rule, {
options: ['multiline-multiprop'],
parser: 'babel-eslint'
},
{
code: [
'<Foo ',
' foo={{',
' }}',
' bar',
'/>'
].join('\n'),
options: ['multiline-multiprop'],
parser: 'typescript-eslint-parser'
},
{
code: '<Foo />',
options: ['always'],
Expand Down Expand Up @@ -167,6 +178,16 @@ ruleTester.run('jsx-first-prop-new-line', rule, {
errors: [{message: 'Property should be placed on a new line'}],
parser: 'babel-eslint'
},
{
code: '<Foo propOne="one" propTwo="two" />',
output: [
'<Foo',
'propOne="one" propTwo="two" />'
].join('\n'),
options: ['always'],
errors: [{message: 'Property should be placed on a new line'}],
parser: 'typescript-eslint-parser'
},
{
code: [
'<Foo propOne="one"',
Expand All @@ -183,6 +204,22 @@ ruleTester.run('jsx-first-prop-new-line', rule, {
errors: [{message: 'Property should be placed on a new line'}],
parser: 'babel-eslint'
},
{
code: [
'<Foo propOne="one"',
' propTwo="two"',
'/>'
].join('\n'),
output: [
'<Foo',
'propOne="one"',
' propTwo="two"',
'/>'
].join('\n'),
options: ['always'],
errors: [{message: 'Property should be placed on a new line'}],
parser: 'typescript-eslint-parser'
},
{
code: [
'<Foo',
Expand All @@ -199,6 +236,22 @@ ruleTester.run('jsx-first-prop-new-line', rule, {
errors: [{message: 'Property should be placed on the same line as the component declaration'}],
parser: 'babel-eslint'
},
{
code: [
'<Foo',
' propOne="one"',
' propTwo="two"',
'/>'
].join('\n'),
output: [
'<Foo propOne="one"',
' propTwo="two"',
'/>'
].join('\n'),
options: ['never'],
errors: [{message: 'Property should be placed on the same line as the component declaration'}],
parser: 'typescript-eslint-parser'
},
{
code: [
'<Foo prop={{',
Expand All @@ -213,6 +266,20 @@ ruleTester.run('jsx-first-prop-new-line', rule, {
errors: [{message: 'Property should be placed on a new line'}],
parser: 'babel-eslint'
},
{
code: [
'<Foo prop={{',
'}} />'
].join('\n'),
output: [
'<Foo',
'prop={{',
'}} />'
].join('\n'),
options: ['multiline'],
errors: [{message: 'Property should be placed on a new line'}],
parser: 'typescript-eslint-parser'
},
{
code: [
'<Foo bar={{',
Expand All @@ -226,6 +293,20 @@ ruleTester.run('jsx-first-prop-new-line', rule, {
options: ['multiline-multiprop'],
errors: [{message: 'Property should be placed on a new line'}],
parser: 'babel-eslint'
},
{
code: [
'<Foo bar={{',
'}} baz />'
].join('\n'),
output: [
'<Foo',
'bar={{',
'}} baz />'
].join('\n'),
options: ['multiline-multiprop'],
errors: [{message: 'Property should be placed on a new line'}],
parser: 'typescript-eslint-parser'
}
]
});

0 comments on commit a7cbf40

Please sign in to comment.