Skip to content

Commit

Permalink
tests for #210.
Browse files Browse the repository at this point in the history
  • Loading branch information
benmosher committed Mar 8, 2016
1 parent 0981907 commit 9b92849
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/files/issue210.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
exports.parserOptions = {
sourceType: 'module',
}
1 change: 1 addition & 0 deletions tests/files/issue210.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { test } from './issue210.js'
2 changes: 2 additions & 0 deletions tests/files/narcissist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const me = 'awesome'
export { me as soGreat } from './narcissist'
25 changes: 25 additions & 0 deletions tests/src/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* tests that require fully booting up ESLint
*/
import { expect } from 'chai'
import { CLIEngine } from 'eslint'

describe('CLI regression tests', function () {
describe('issue #210', function () {
this.timeout(10000)
let cli
before(function () {
cli = new CLIEngine({
useEslintrc: false,
configFile: './tests/files/issue210.config.js',
rulePaths: ['./lib/rules'],
rules: {
'named': 2,
},
})
})
it("doesn't throw an error on gratuitous, erroneous self-reference", function () {
expect(() => cli.executeOnFiles(['./tests/files/issue210.js'])).not.to.throw(Error)
})
})
})
14 changes: 14 additions & 0 deletions tests/src/core/getExports.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,4 +264,18 @@ describe('getExports', function () {
})
})

context('issue #210: self-reference', function () {
it("doesn't crash", function () {
expect(() => ExportMap.get('./narcissist', fakeContext)).not.to.throw(Error)
})
it("'has' circular reference", function () {
expect(ExportMap.get('./narcissist', fakeContext))
.to.exist.and.satisfy(m => m.has('soGreat'))
})
it("can 'get' circular reference", function () {
expect(ExportMap.get('./narcissist', fakeContext))
.to.exist.and.satisfy(m => m.get('soGreat') != null)
})
})

})
3 changes: 3 additions & 0 deletions tests/src/rules/named.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ ruleTester.run('named', rule, {
// ignore is ignored if exports are found
test({ code: 'import { foo } from "es6-module"' }),

// issue #210: shameless self-reference
test({ code: 'import { me, soGreat } from "./narcissist"' }),

],

invalid: [
Expand Down

0 comments on commit 9b92849

Please sign in to comment.