Skip to content

Commit

Permalink
Add more tests for ordering around function call
Browse files Browse the repository at this point in the history
  • Loading branch information
tihonove committed Feb 17, 2019
1 parent eddc118 commit f90a614
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions tests/src/rules/order.js
Expand Up @@ -1238,6 +1238,52 @@ ruleTester.run('order', rule, {
'`./local4` import should occur after import of `global5`',
],
}),
// reorder fix cannot cross function call on moving below
test(withoutAutofixOutput({
code: `
const local = require('./local');
const global1 = require('global1');
const global2 = require('global2');
fn_call();
const global3 = require('global3');
fn_call();
`,
errors: [{
ruleId: 'order',
message: '`./local` import should occur after import of `global3`',
}],
})),
// reorder fix cannot cross function call on moving below
// fix imports that not crosses function call only
test({
code: `
const local1 = require('./local1');
const global1 = require('global1');
const global2 = require('global2');
fn_call();
const local2 = require('./local2');
const global3 = require('global3');
const global4 = require('global4');
fn_call();
`,
output: `
const local1 = require('./local1');
const global1 = require('global1');
const global2 = require('global2');
fn_call();
const global3 = require('global3');
const global4 = require('global4');
const local2 = require('./local2');
fn_call();
`,
errors: [
'`./local1` import should occur after import of `global4`',
'`./local2` import should occur after import of `global4`',
],
}),
// reorder fix cannot cross non import or require
test(withoutAutofixOutput({
code: `
Expand Down

0 comments on commit f90a614

Please sign in to comment.