Skip to content

Commit

Permalink
Adds a test
Browse files Browse the repository at this point in the history
  • Loading branch information
arcanis committed Jan 3, 2020
1 parent 64f0452 commit 305e798
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions tests/src/core/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ describe('resolve', function () {
)).to.equal(utils.testFilePath('./bar.jsx'))
})

it('finds resolvers from the source files rather than eslint-module-utils', function () {
const testContext = utils.testContext({ 'import/resolver': { 'foo': {} } })

expect(resolve( '../files/foo'
, Object.assign({}, testContext, { getFilename: function () { return utils.getFilename('foo.js') } }),
)).to.equal(utils.testFilePath('./bar.jsx'))
})

it('reports invalid import/resolver config', function () {
const testContext = utils.testContext({ 'import/resolver': 123.456 })
const testContextReports = []
Expand Down
8 changes: 4 additions & 4 deletions tests/src/rules/no-unresolved.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,19 +343,19 @@ ruleTester.run('no-unresolved unknown resolver', rule, {
// logs resolver load error
test({
code: 'import "./malformed.js"',
settings: { 'import/resolver': 'foo' },
settings: { 'import/resolver': 'doesnt-exist' },
errors: [
`Resolve error: unable to load resolver "foo".`,
`Resolve error: unable to load resolver "doesnt-exist".`,
`Unable to resolve path to module './malformed.js'.`,
],
}),

// only logs resolver message once
test({
code: 'import "./malformed.js"; import "./fake.js"',
settings: { 'import/resolver': 'foo' },
settings: { 'import/resolver': 'doesnt-exist' },
errors: [
`Resolve error: unable to load resolver "foo".`,
`Resolve error: unable to load resolver "doesnt-exist".`,
`Unable to resolve path to module './malformed.js'.`,
`Unable to resolve path to module './fake.js'.`,
],
Expand Down

0 comments on commit 305e798

Please sign in to comment.