From f90a614a3a2176de883e6e269b3358616d70521a Mon Sep 17 00:00:00 2001 From: Eugene Tihonov Date: Fri, 4 Jan 2019 01:46:10 +0500 Subject: [PATCH] Add more tests for ordering around function call --- tests/src/rules/order.js | 46 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/tests/src/rules/order.js b/tests/src/rules/order.js index 3ffa4b8a1d..0dce831e46 100644 --- a/tests/src/rules/order.js +++ b/tests/src/rules/order.js @@ -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: `