forked from AtomLinter/linter-shellcheck
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bring in `jasmine-fix` to allow the use of `async`/`await` in the specs and refactor them to take advantage of this.
- Loading branch information
1 parent
d4d2b19
commit 851510f
Showing
2 changed files
with
26 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,47 @@ | ||
'use babel'; | ||
|
||
import * as path from 'path'; | ||
// eslint-disable-next-line no-unused-vars | ||
import { it, fit, wait, beforeEach, afterEach } from 'jasmine-fix'; | ||
|
||
const { lint } = require('../lib/main.js').provideLinter(); | ||
|
||
const cleanPath = path.join(__dirname, 'fixtures', 'clean.sh'); | ||
const badPath = path.join(__dirname, 'fixtures', 'bad.sh'); | ||
|
||
describe('The ShellCheck provider for Linter', () => { | ||
const { lint } = require('../lib/main.js').provideLinter(); | ||
|
||
beforeEach(() => { | ||
beforeEach(async () => { | ||
atom.workspace.destroyActivePaneItem(); | ||
|
||
// Info about this beforeEach() implementation: | ||
// https://github.com/AtomLinter/Meta/issues/15 | ||
const activationPromise = | ||
atom.packages.activatePackage('linter-shellcheck'); | ||
const activationPromise = atom.packages.activatePackage('linter-shellcheck'); | ||
|
||
waitsForPromise(() => | ||
atom.packages.activatePackage('language-shellscript').then(() => | ||
atom.workspace.open(cleanPath))); | ||
await atom.packages.activatePackage('language-shellscript'); | ||
await atom.workspace.open(cleanPath); | ||
|
||
atom.packages.triggerDeferredActivationHooks(); | ||
waitsForPromise(() => activationPromise); | ||
await activationPromise; | ||
}); | ||
|
||
it('finds nothing wrong with a valid file', () => { | ||
waitsForPromise(() => | ||
atom.workspace.open(cleanPath).then(editor => lint(editor)).then((messages) => { | ||
expect(messages.length).toBe(0); | ||
})); | ||
it('finds nothing wrong with a valid file', async () => { | ||
const editor = await atom.workspace.open(cleanPath); | ||
const messages = await lint(editor); | ||
|
||
expect(messages.length).toBe(0); | ||
}); | ||
|
||
it('handles messages from ShellCheck', () => { | ||
it('handles messages from ShellCheck', async () => { | ||
const expectedMsg = 'Tips depend on target shell and yours is unknown. Add a shebang. ' + | ||
'[<a href="https://github.com/koalaman/shellcheck/wiki/SC2148">SC2148</a>]'; | ||
waitsForPromise(() => | ||
atom.workspace.open(badPath).then(editor => lint(editor)).then((messages) => { | ||
expect(messages.length).toBe(1); | ||
expect(messages[0].type).toBe('error'); | ||
expect(messages[0].text).not.toBeDefined(); | ||
expect(messages[0].html).toBe(expectedMsg); | ||
expect(messages[0].filePath).toBe(badPath); | ||
expect(messages[0].range).toEqual([[0, 0], [0, 4]]); | ||
})); | ||
const editor = await atom.workspace.open(badPath); | ||
const messages = await lint(editor); | ||
|
||
expect(messages.length).toBe(1); | ||
expect(messages[0].type).toBe('error'); | ||
expect(messages[0].text).not.toBeDefined(); | ||
expect(messages[0].html).toBe(expectedMsg); | ||
expect(messages[0].filePath).toBe(badPath); | ||
expect(messages[0].range).toEqual([[0, 0], [0, 4]]); | ||
}); | ||
}); |