From 50ef76716a19e4befc710a44e50ecace01718aed Mon Sep 17 00:00:00 2001 From: Ivan Rubinson Date: Thu, 24 Oct 2019 23:11:59 +0300 Subject: [PATCH] [Tests] `no-cycle`: Add tests for commonjs imports --- tests/files/cycles/cjs/depth-one.js | 2 ++ tests/files/cycles/cjs/depth-three-indirect.js | 5 +++++ tests/files/cycles/cjs/depth-three-star.js | 2 ++ tests/files/cycles/cjs/depth-two.js | 2 ++ tests/src/rules/no-cycle.js | 2 +- 5 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 tests/files/cycles/cjs/depth-one.js create mode 100644 tests/files/cycles/cjs/depth-three-indirect.js create mode 100644 tests/files/cycles/cjs/depth-three-star.js create mode 100644 tests/files/cycles/cjs/depth-two.js diff --git a/tests/files/cycles/cjs/depth-one.js b/tests/files/cycles/cjs/depth-one.js new file mode 100644 index 000000000..1a38865fd --- /dev/null +++ b/tests/files/cycles/cjs/depth-one.js @@ -0,0 +1,2 @@ +var foo = require("../depth-zero") +module.exports = { foo } diff --git a/tests/files/cycles/cjs/depth-three-indirect.js b/tests/files/cycles/cjs/depth-three-indirect.js new file mode 100644 index 000000000..d6bc9dd2b --- /dev/null +++ b/tests/files/cycles/cjs/depth-three-indirect.js @@ -0,0 +1,5 @@ +require('./depth-two') + +module.exports = function bar() { + return "side effects???" +} diff --git a/tests/files/cycles/cjs/depth-three-star.js b/tests/files/cycles/cjs/depth-three-star.js new file mode 100644 index 000000000..c605fa5a5 --- /dev/null +++ b/tests/files/cycles/cjs/depth-three-star.js @@ -0,0 +1,2 @@ +var two = require("./depth-two") +module.exports = { two } diff --git a/tests/files/cycles/cjs/depth-two.js b/tests/files/cycles/cjs/depth-two.js new file mode 100644 index 000000000..b46a709e2 --- /dev/null +++ b/tests/files/cycles/cjs/depth-two.js @@ -0,0 +1,2 @@ +var { foo } = require("./depth-one") +module.exports = { foo } diff --git a/tests/src/rules/no-cycle.js b/tests/src/rules/no-cycle.js index 11fc515f0..eedb81977 100644 --- a/tests/src/rules/no-cycle.js +++ b/tests/src/rules/no-cycle.js @@ -12,7 +12,7 @@ const test = def => _test(Object.assign(def, { filename: testFilePath('./cycles/depth-zero.js'), })); -const testDialects = ['es6']; +const testDialects = ['es6', 'cjs']; ruleTester.run('no-cycle', rule, { valid: [].concat(