Skip to content

Commit

Permalink
[Fix] import-js#2882 Restore modified tests (i.e. modified tests beco…
Browse files Browse the repository at this point in the history
…me new tests)
  • Loading branch information
kinland committed Sep 26, 2023
1 parent fbbb18a commit 06e8759
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions tests/src/rules/newline-after-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ ruleTester.run('newline-after-import', require('rules/newline-after-import'), {
parserOptions: { ecmaVersion: 2015, sourceType: 'module' },
options: [{ count: 2 }],
},
{
code: `import foo from 'foo';\n\n\nvar bar = 'bar';`,
parserOptions: { ecmaVersion: 2015, sourceType: 'module' },
options: [{ count: 2, exactCount: true }],
},
{
code: `import foo from 'foo';\n\nvar bar = 'bar';`,
parserOptions: { ecmaVersion: 2015, sourceType: 'module' },
options: [{ count: 1, exactCount: true }],
},
{
code: `import foo from 'foo';\n\n// Some random comment\nvar bar = 'bar';`,
parserOptions: { ecmaVersion: 2015, sourceType: 'module' },
Expand Down Expand Up @@ -181,6 +191,11 @@ ruleTester.run('newline-after-import', require('rules/newline-after-import'), {
parserOptions: { ecmaVersion: 2015, sourceType: 'module' },
options: [{ count: 4 }],
},
{
code: `var foo = require('foo-module');\n\n\n\n\nvar foo = 'bar';`,
parserOptions: { ecmaVersion: 2015, sourceType: 'module' },
options: [{ count: 4, exactCount: true }],
},
{
code: `var foo = require('foo-module');\n\n// Some random comment\n\n\nvar foo = 'bar';`,
parserOptions: { ecmaVersion: 2015, sourceType: 'module' },
Expand Down Expand Up @@ -670,6 +685,39 @@ ruleTester.run('newline-after-import', require('rules/newline-after-import'), {
parserOptions: { sourceType: 'module' },
parser: parsers.BABEL_OLD,
})) || [],
{
code: `import foo from 'foo';\n\nexport default function() {};`,
output: `import foo from 'foo';\n\n\nexport default function() {};`,
options: [{ count: 2, exactCount: true }],
errors: [{
line: 1,
column: 1,
message: IMPORT_ERROR_MESSAGE_MULTIPLE(2),
}],
parserOptions: { ecmaVersion: 2015, sourceType: 'module' },
},
{
code: `import foo from 'foo';\n\n\n\nexport default function() {};`,
output: `import foo from 'foo';\n\n\n\nexport default function() {};`,
options: [{ count: 2, exactCount: true }],
errors: [{
line: 1,
column: 1,
message: IMPORT_ERROR_MESSAGE_MULTIPLE(2),
}],
parserOptions: { ecmaVersion: 2015, sourceType: 'module' },
},
{
code: `import foo from 'foo';\n\n\n\n\nexport default function() {};`,
output: `import foo from 'foo';\n\n\n\n\nexport default function() {};`,
options: [{ count: 2, exactCount: true }],
errors: [{
line: 1,
column: 1,
message: IMPORT_ERROR_MESSAGE_MULTIPLE(2),
}],
parserOptions: { ecmaVersion: 2015, sourceType: 'module' },
},
{
code: `import foo from 'foo';\n// some random comment\nexport default function() {};`,
output: `import foo from 'foo';\n\n// some random comment\nexport default function() {};`,
Expand Down Expand Up @@ -770,6 +818,17 @@ ruleTester.run('newline-after-import', require('rules/newline-after-import'), {
}],
parserOptions: { ecmaVersion: 2015, sourceType: 'module' },
},
{
code: `const foo = require('foo');\n\n\n\nconst bar = function() {};`,
output: `const foo = require('foo');\n\n\n\nconst bar = function() {};`,
options: [{ count: 2, exactCount: true }],
errors: [{
line: 1,
column: 1,
message: 'Expected 2 empty lines after require statement not followed by another require.',
}],
parserOptions: { ecmaVersion: 2015 },
},
{
code: `const foo = require('foo');\n\n\n\n// some random comment\nconst bar = function() {};`,
output: `const foo = require('foo');\n\n\n\n// some random comment\nconst bar = function() {};`,
Expand Down

0 comments on commit 06e8759

Please sign in to comment.