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

Asyncify the specs #229

Merged
merged 1 commit into from
Sep 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@
"devDependencies": {
"eslint": "^4.6.0",
"eslint-config-airbnb-base": "^12.0.0",
"eslint-plugin-import": "^2.7.0"
"eslint-plugin-import": "^2.7.0",
"jasmine-fix": "^1.3.1"
},
"package-deps": [
"linter:2.0.0"
Expand Down
85 changes: 36 additions & 49 deletions spec/linter-pylint-spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'use babel';

import * as path from 'path';
// eslint-disable-next-line no-unused-vars
import { it, fit, wait, beforeEach, afterEach } from 'jasmine-fix';

const goodPath = path.join(__dirname, 'files', 'good.py');
const badPath = path.join(__dirname, 'files', 'bad.py');
Expand All @@ -11,13 +13,9 @@ const { lint } = require('../lib/main.js').provideLinter();
const wikiURLBase = 'http://pylint-messages.wikidot.com/messages:';

describe('The pylint provider for Linter', () => {
beforeEach(() => {
waitsForPromise(() =>
Promise.all([
atom.packages.activatePackage('linter-pylint'),
atom.packages.activatePackage('language-python').then(() =>
atom.workspace.open(goodPath)),
]));
beforeEach(async () => {
await atom.packages.activatePackage('linter-pylint');
await atom.packages.activatePackage('language-python');
});

it('should be in the packages list', () =>
Expand All @@ -26,51 +24,40 @@ describe('The pylint provider for Linter', () => {
it('should be an active package', () =>
expect(atom.packages.isPackageActive('linter-pylint')).toBe(true));

describe('checks bad.py and', () => {
let editor = null;
beforeEach(() => {
waitsForPromise(() =>
atom.workspace.open(badPath).then((openEditor) => {
editor = openEditor;
}));
});

it('finds at least one message', () =>
waitsForPromise(() =>
lint(editor).then(messages => expect(messages.length).toBeGreaterThan(0))));

it('verifies that message', () =>
waitsForPromise(() =>
lint(editor).then((messages) => {
expect(messages[0].severity).toBe('info');
expect(messages[0].excerpt).toBe('C0111 Missing module docstring');
expect(messages[0].location.file).toBe(badPath);
expect(messages[0].location.position).toEqual([[0, 0], [0, 4]]);
expect(messages[0].url).toBe(`${wikiURLBase}C0111`);

expect(messages[1].severity).toBe('warning');
expect(messages[1].excerpt).toBe('W0104 Statement seems to have no effect');
expect(messages[1].location.file).toBe(badPath);
expect(messages[1].location.position).toEqual([[0, 0], [0, 4]]);
expect(messages[1].url).toBe(`${wikiURLBase}W0104`);

expect(messages[2].severity).toBe('error');
expect(messages[2].excerpt).toBe("E0602 Undefined variable 'asfd'");
expect(messages[2].location.file).toBe(badPath);
expect(messages[2].location.position).toEqual([[0, 0], [0, 4]]);
expect(messages[2].url).toBe(`${wikiURLBase}E0602`);
})));
it('checks bad.py and reports the correct results', async () => {
const editor = await atom.workspace.open(badPath);
const messages = await lint(editor);

expect(messages.length).toBe(3);

expect(messages[0].severity).toBe('info');
expect(messages[0].excerpt).toBe('C0111 Missing module docstring');
expect(messages[0].location.file).toBe(badPath);
expect(messages[0].location.position).toEqual([[0, 0], [0, 4]]);
expect(messages[0].url).toBe(`${wikiURLBase}C0111`);

expect(messages[1].severity).toBe('warning');
expect(messages[1].excerpt).toBe('W0104 Statement seems to have no effect');
expect(messages[1].location.file).toBe(badPath);
expect(messages[1].location.position).toEqual([[0, 0], [0, 4]]);
expect(messages[1].url).toBe(`${wikiURLBase}W0104`);

expect(messages[2].severity).toBe('error');
expect(messages[2].excerpt).toBe("E0602 Undefined variable 'asfd'");
expect(messages[2].location.file).toBe(badPath);
expect(messages[2].location.position).toEqual([[0, 0], [0, 4]]);
expect(messages[2].url).toBe(`${wikiURLBase}E0602`);
});

it('finds nothing wrong with an empty file', () => {
waitsForPromise(() =>
atom.workspace.open(emptyPath).then(editor =>
lint(editor).then(messages => expect(messages.length).toBe(0))));
it('finds nothing wrong with an empty file', async () => {
const editor = await atom.workspace.open(emptyPath);
const messages = await lint(editor);
expect(messages.length).toBe(0);
});

it('finds nothing wrong with a valid file', () => {
waitsForPromise(() =>
atom.workspace.open(goodPath).then(editor =>
lint(editor).then(messages => expect(messages.length).toBe(0))));
it('finds nothing wrong with a valid file', async () => {
const editor = await atom.workspace.open(goodPath);
const messages = await lint(editor);
expect(messages.length).toBe(0);
});
});