diff --git a/package.json b/package.json index 0da62ee..1888d43 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ "devDependencies": { "eslint": "^4.6.0", "eslint-config-airbnb-base": "^12.0.0", - "eslint-plugin-import": "^2.7.0" + "eslint-plugin-import": "^2.7.0", + "jasmine-fix": "^1.3.1" }, "eslintConfig": { "extends": "airbnb-base", diff --git a/spec/linter-shellcheck-spec.js b/spec/linter-shellcheck-spec.js index e9145e8..dc43e2d 100644 --- a/spec/linter-shellcheck-spec.js +++ b/spec/linter-shellcheck-spec.js @@ -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. ' + '[SC2148]'; - 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]]); }); });