This repository was archived by the owner on Aug 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlinter-stylint-spec.js
67 lines (55 loc) · 2.49 KB
/
linter-stylint-spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
'use babel';
import {
// eslint-disable-next-line no-unused-vars
it, fit, wait, beforeEach, afterEach,
} from 'jasmine-fix';
import path from 'path';
const { lint } = require('../lib/init').provideLinter();
const goodPug = path.join(__dirname, 'fixtures', 'config', 'good.pug');
const badPug = path.join(__dirname, 'fixtures', 'config', 'bad.pug');
const noConfigRule = path.join(__dirname, 'fixtures', 'noConfig', 'badRule.pug');
const noConfigSyntax = path.join(__dirname, 'fixtures', 'noConfig', 'badSyntax.pug');
describe('The pug-lint provider for Linter', () => {
beforeEach(async () => {
atom.workspace.destroyActivePaneItem();
await atom.packages.activatePackage('linter-pug');
});
it('should be in the packages list',
() => expect(atom.packages.isPackageLoaded('linter-pug')).toBe(true));
it('should be an active package',
() => expect(atom.packages.isPackageActive('linter-pug')).toBe(true));
describe('works with a configuration', () => {
it('finds nothing wrong with valid file', async () => {
const editor = await atom.workspace.open(goodPug);
const messages = await lint(editor);
expect(messages.length).toBe(0);
});
it('finds something wrong with invalid file', async () => {
const errMsg = 'Attribute interpolation operators must not be used';
const editor = await atom.workspace.open(badPug);
const messages = await lint(editor);
expect(messages.length).toEqual(1);
expect(messages[0].description).not.toBeDefined();
expect(messages[0].excerpt).toBe(errMsg);
expect(messages[0].location.file).toBe(badPug);
expect(messages[0].location.position).toEqual([[0, 13], [0, 20]]);
});
});
describe('works without a configuration', () => {
it('finds nothing wrong with a "bad" file', async () => {
const editor = await atom.workspace.open(noConfigRule);
const messages = await lint(editor);
expect(messages.length).toBe(0);
});
it('finds syntax errors without a configuration', async () => {
const errMsg = 'The end of the string reached with no closing bracket ) found.';
const editor = await atom.workspace.open(noConfigSyntax);
const messages = await lint(editor);
expect(messages.length).toEqual(1);
expect(messages[0].description).not.toBeDefined();
expect(messages[0].excerpt).toBe(errMsg);
expect(messages[0].location.file).toBe(noConfigSyntax);
expect(messages[0].location.position).toEqual([[1, 0], [1, 0]]);
});
});
});