Skip to content

Commit

Permalink
test: add a failing test for no-unused-modules / destructured exports
Browse files Browse the repository at this point in the history
  • Loading branch information
KristjanTammekivi committed Apr 27, 2021
1 parent e871a9a commit aecb641
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/src/rules/no-unused-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,33 @@ describe('test behaviour for new file', () => {
});
});

describe('test behaviour for destructured exports', () => {
before(() => {
fs.writeFileSync(testFilePath('./no-unused-modules/file-added-3.js'), '', { encoding: 'utf8' });
});
ruleTester.run('no-unused-modules', rule, {
valid: [
test({ options: unusedExportsOptions,
code: `import { added } from '${testFilePath('./no-unused-modules/file-added-3.js')}'`,
filename: testFilePath('./no-unused-modules/file-added-1.js') }),
test({ options: unusedExportsOptions,
code: `export const { added } = {};`,
filename: testFilePath('./no-unused-modules/file-added-3.js') }),
],
invalid: [
test({ options: unusedExportsOptions,
code: `export const { added } = {};`,
filename: testFilePath('./no-unused-modules/file-added-3.js'),
errors: [`exported declaration 'added' not used within other modules`] }),
],
});
after(() => {
if (fs.existsSync(testFilePath('./no-unused-modules/file-added-3.js'))) {
fs.unlinkSync(testFilePath('./no-unused-modules/file-added-3.js'));
}
});
});

describe('test behaviour for new file', () => {
before(() => {
fs.writeFileSync(testFilePath('./no-unused-modules/file-added-4.js.js'), '', { encoding: 'utf8' });
Expand Down

0 comments on commit aecb641

Please sign in to comment.