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

Commit ec4a638

Browse files
authored
Merge pull request #106 from AtomLinter/arcanemagus/asyncify-specs
Asyncify the specs
2 parents d4d2b19 + 851510f commit ec4a638

File tree

2 files changed

+26
-25
lines changed

2 files changed

+26
-25
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
"devDependencies": {
4141
"eslint": "^4.6.0",
4242
"eslint-config-airbnb-base": "^12.0.0",
43-
"eslint-plugin-import": "^2.7.0"
43+
"eslint-plugin-import": "^2.7.0",
44+
"jasmine-fix": "^1.3.1"
4445
},
4546
"eslintConfig": {
4647
"extends": "airbnb-base",

spec/linter-shellcheck-spec.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
11
'use babel';
22

33
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();
48

59
const cleanPath = path.join(__dirname, 'fixtures', 'clean.sh');
610
const badPath = path.join(__dirname, 'fixtures', 'bad.sh');
711

812
describe('The ShellCheck provider for Linter', () => {
9-
const { lint } = require('../lib/main.js').provideLinter();
10-
11-
beforeEach(() => {
13+
beforeEach(async () => {
1214
atom.workspace.destroyActivePaneItem();
1315

1416
// Info about this beforeEach() implementation:
1517
// https://github.com/AtomLinter/Meta/issues/15
16-
const activationPromise =
17-
atom.packages.activatePackage('linter-shellcheck');
18+
const activationPromise = atom.packages.activatePackage('linter-shellcheck');
1819

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);
2222

2323
atom.packages.triggerDeferredActivationHooks();
24-
waitsForPromise(() => activationPromise);
24+
await activationPromise;
2525
});
2626

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);
3232
});
3333

34-
it('handles messages from ShellCheck', () => {
34+
it('handles messages from ShellCheck', async () => {
3535
const expectedMsg = 'Tips depend on target shell and yours is unknown. Add a shebang. ' +
3636
'[<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]]);
4646
});
4747
});

0 commit comments

Comments
 (0)