Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Commit

Permalink
Add spec for showRuleIdInMessage
Browse files Browse the repository at this point in the history
Add a spec testing that the "Show Rule ID in Messages" option works as
expected.

Fixes #473.
  • Loading branch information
Arcanemagus committed May 22, 2017
1 parent d23a738 commit 79fd968
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions spec/linter-eslint-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,4 +528,38 @@ describe('The eslint provider for Linter', () => {
expect(scopes.includes(embeddedScope)).toBe(true)
})
})

describe('handles the Show Rule ID in Messages option', () => {
const expectedUrl = 'https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md'

it('shows the rule ID when enabled', async () => {
atom.config.set('linter-eslint.showRuleIdInMessage', true)
const editor = await atom.workspace.open(badImportPath)
const messages = await lint(editor)
const expected = "Unable to resolve path to module '../nonexistent'. (import/no-unresolved)"

expect(messages.length).toBe(1)
expect(messages[0].severity).toBe('error')
expect(messages[0].excerpt).toBe(expected)
expect(messages[0].url).toBe(expectedUrl)
expect(messages[0].location.file).toBe(badImportPath)
expect(messages[0].location.position).toEqual([[0, 24], [0, 39]])
expect(messages[0].solutions).not.toBeDefined()
})

it("doesn't show the rule ID when disabled", async () => {
atom.config.set('linter-eslint.showRuleIdInMessage', false)
const editor = await atom.workspace.open(badImportPath)
const messages = await lint(editor)
const expected = "Unable to resolve path to module '../nonexistent'."

expect(messages.length).toBe(1)
expect(messages[0].severity).toBe('error')
expect(messages[0].excerpt).toBe(expected)
expect(messages[0].url).toBe(expectedUrl)
expect(messages[0].location.file).toBe(badImportPath)
expect(messages[0].location.position).toEqual([[0, 24], [0, 39]])
expect(messages[0].solutions).not.toBeDefined()
})
})
})

0 comments on commit 79fd968

Please sign in to comment.