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

Commit ad82e97

Browse files
committed
Use async/await in specs
Requires the `jasmine-fix` module to get them working.
1 parent 67c450f commit ad82e97

File tree

2 files changed

+48
-54
lines changed

2 files changed

+48
-54
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"devDependencies": {
3131
"eslint": "^3.13.0",
3232
"eslint-config-airbnb-base": "^11.0.1",
33-
"eslint-plugin-import": "^2.2.0"
33+
"eslint-plugin-import": "^2.2.0",
34+
"jasmine-fix": "^1.0.1"
3435
},
3536
"package-deps": [
3637
"linter"

spec/linter-clang-spec.js

Lines changed: 46 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,57 @@
11
'use babel';
22

3-
import * as path from 'path';
3+
// eslint-disable-next-line import/no-extraneous-dependencies
4+
import { beforeEach, it } from 'jasmine-fix';
5+
import { join } from 'path';
46

5-
const miPath = path.join(__dirname, 'files', 'missing_import');
6-
const validPath = path.join(__dirname, 'files', 'valid.c');
7+
const lint = require('../lib/main').provideLinter().lint;
78

8-
describe('The Clang provider for AtomLinter', () => {
9-
const lint = require('../lib/main').provideLinter().lint;
10-
11-
beforeEach(() => {
12-
waitsForPromise(() => atom.packages.activatePackage('linter-clang'));
13-
});
14-
15-
it('finds nothing wrong with a valid file', () => {
16-
waitsForPromise(() =>
17-
atom.workspace.open(validPath).then(editor =>
18-
lint(editor).then((messages) => {
19-
expect(messages.length).toBe(0);
20-
}),
21-
),
22-
);
23-
});
24-
25-
it('finds a fatal error in "missing_import.c"', () => {
26-
waitsForPromise(() => atom.workspace.open(`${miPath}.c`).then(
27-
editor => lint(editor).then((messages) => {
28-
expect(messages.length).toEqual(1);
29-
expect(messages[0].type).toEqual('fatal error');
30-
expect(messages[0].text).toEqual("'nothing.h' file not found");
31-
}),
32-
));
33-
});
9+
const miPath = join(__dirname, 'files', 'missing_import');
10+
const validPath = join(__dirname, 'files', 'valid.c');
3411

35-
it('finds a fatal error in "missing_import.cpp"', () => {
36-
waitsForPromise(() => atom.workspace.open(`${miPath}.cpp`).then(
37-
editor => lint(editor).then((messages) => {
38-
expect(messages.length).toEqual(1);
39-
expect(messages[0].type).toEqual('fatal error');
40-
expect(messages[0].text).toEqual("'nothing.h' file not found");
41-
}),
42-
));
12+
describe('The Clang provider for AtomLinter', () => {
13+
beforeEach(async () => {
14+
await atom.packages.activatePackage('language-c');
15+
await atom.packages.activatePackage('linter-clang');
4316
});
4417

45-
it('finds a fatal error in "missing_import.m"', () => {
46-
waitsForPromise(() => atom.workspace.open(`${miPath}.m`).then(
47-
editor => lint(editor).then((messages) => {
48-
expect(messages.length).toEqual(1);
49-
expect(messages[0].type).toEqual('fatal error');
50-
expect(messages[0].text).toEqual("'nothing.h' file not found");
51-
}),
52-
));
18+
it('finds nothing wrong with a valid file', async () => {
19+
const editor = await atom.workspace.open(validPath);
20+
const messages = await lint(editor);
21+
expect(messages.length).toBe(0);
5322
});
5423

55-
it('finds a fatal error in "missing_import.mm"', () => {
56-
waitsForPromise(() => atom.workspace.open(`${miPath}.mm`).then(
57-
editor => lint(editor).then((messages) => {
58-
expect(messages.length).toEqual(1);
59-
expect(messages[0].type).toEqual('fatal error');
60-
expect(messages[0].text).toEqual("'nothing.h' file not found");
61-
}),
62-
));
24+
describe('handles errors in different file types', () => {
25+
it('finds a fatal error in "missing_import.c"', async () => {
26+
const editor = await atom.workspace.open(`${miPath}.c`);
27+
const messages = await lint(editor);
28+
expect(messages.length).toBe(1);
29+
expect(messages[0].type).toBe('fatal error');
30+
expect(messages[0].text).toBe("'nothing.h' file not found");
31+
});
32+
33+
it('finds a fatal error in "missing_import.cpp"', async () => {
34+
const editor = await atom.workspace.open(`${miPath}.cpp`);
35+
const messages = await lint(editor);
36+
expect(messages.length).toBe(1);
37+
expect(messages[0].type).toEqual('fatal error');
38+
expect(messages[0].text).toEqual("'nothing.h' file not found");
39+
});
40+
41+
it('finds a fatal error in "missing_import.m"', async () => {
42+
const editor = await atom.workspace.open(`${miPath}.m`);
43+
const messages = await lint(editor);
44+
expect(messages.length).toBe(1);
45+
expect(messages[0].type).toEqual('fatal error');
46+
expect(messages[0].text).toEqual("'nothing.h' file not found");
47+
});
48+
49+
it('finds a fatal error in "missing_import.mm"', async () => {
50+
const editor = await atom.workspace.open(`${miPath}.mm`);
51+
const messages = await lint(editor);
52+
expect(messages.length).toBe(1);
53+
expect(messages[0].type).toEqual('fatal error');
54+
expect(messages[0].text).toEqual("'nothing.h' file not found");
55+
});
6356
});
6457
});

0 commit comments

Comments
 (0)