|
1 | 1 | 'use babel';
|
2 | 2 |
|
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'; |
4 | 6 |
|
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; |
7 | 8 |
|
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'); |
34 | 11 |
|
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'); |
43 | 16 | });
|
44 | 17 |
|
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); |
53 | 22 | });
|
54 | 23 |
|
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 | + }); |
63 | 56 | });
|
64 | 57 | });
|
0 commit comments