|
1 | 1 | 'use babel'; |
2 | 2 |
|
3 | 3 | import * as path from 'path'; |
| 4 | +// eslint-disable-next-line no-unused-vars |
| 5 | +import { it, fit, wait, beforeEach, afterEach } from 'jasmine-fix'; |
| 6 | + |
| 7 | +const { lint } = require('../lib/main.js').provideLinter(); |
4 | 8 |
|
5 | 9 | const cleanPath = path.join(__dirname, 'fixtures', 'clean.sh'); |
6 | 10 | const badPath = path.join(__dirname, 'fixtures', 'bad.sh'); |
7 | 11 |
|
8 | 12 | describe('The ShellCheck provider for Linter', () => { |
9 | | - const { lint } = require('../lib/main.js').provideLinter(); |
10 | | - |
11 | | - beforeEach(() => { |
| 13 | + beforeEach(async () => { |
12 | 14 | atom.workspace.destroyActivePaneItem(); |
13 | 15 |
|
14 | 16 | // Info about this beforeEach() implementation: |
15 | 17 | // https://github.com/AtomLinter/Meta/issues/15 |
16 | | - const activationPromise = |
17 | | - atom.packages.activatePackage('linter-shellcheck'); |
| 18 | + const activationPromise = atom.packages.activatePackage('linter-shellcheck'); |
18 | 19 |
|
19 | | - waitsForPromise(() => |
20 | | - atom.packages.activatePackage('language-shellscript').then(() => |
21 | | - atom.workspace.open(cleanPath))); |
| 20 | + await atom.packages.activatePackage('language-shellscript'); |
| 21 | + await atom.workspace.open(cleanPath); |
22 | 22 |
|
23 | 23 | atom.packages.triggerDeferredActivationHooks(); |
24 | | - waitsForPromise(() => activationPromise); |
| 24 | + await activationPromise; |
25 | 25 | }); |
26 | 26 |
|
27 | | - it('finds nothing wrong with a valid file', () => { |
28 | | - waitsForPromise(() => |
29 | | - atom.workspace.open(cleanPath).then(editor => lint(editor)).then((messages) => { |
30 | | - expect(messages.length).toBe(0); |
31 | | - })); |
| 27 | + it('finds nothing wrong with a valid file', async () => { |
| 28 | + const editor = await atom.workspace.open(cleanPath); |
| 29 | + const messages = await lint(editor); |
| 30 | + |
| 31 | + expect(messages.length).toBe(0); |
32 | 32 | }); |
33 | 33 |
|
34 | | - it('handles messages from ShellCheck', () => { |
| 34 | + it('handles messages from ShellCheck', async () => { |
35 | 35 | const expectedMsg = 'Tips depend on target shell and yours is unknown. Add a shebang. ' + |
36 | 36 | '[<a href="https://github.com/koalaman/shellcheck/wiki/SC2148">SC2148</a>]'; |
37 | | - waitsForPromise(() => |
38 | | - atom.workspace.open(badPath).then(editor => lint(editor)).then((messages) => { |
39 | | - expect(messages.length).toBe(1); |
40 | | - expect(messages[0].type).toBe('error'); |
41 | | - expect(messages[0].text).not.toBeDefined(); |
42 | | - expect(messages[0].html).toBe(expectedMsg); |
43 | | - expect(messages[0].filePath).toBe(badPath); |
44 | | - expect(messages[0].range).toEqual([[0, 0], [0, 4]]); |
45 | | - })); |
| 37 | + const editor = await atom.workspace.open(badPath); |
| 38 | + const messages = await lint(editor); |
| 39 | + |
| 40 | + expect(messages.length).toBe(1); |
| 41 | + expect(messages[0].type).toBe('error'); |
| 42 | + expect(messages[0].text).not.toBeDefined(); |
| 43 | + expect(messages[0].html).toBe(expectedMsg); |
| 44 | + expect(messages[0].filePath).toBe(badPath); |
| 45 | + expect(messages[0].range).toEqual([[0, 0], [0, 4]]); |
46 | 46 | }); |
47 | 47 | }); |
0 commit comments