Skip to content

Commit

Permalink
✅ Add specs
Browse files Browse the repository at this point in the history
Implement specs and add lint.

Fix AtomLinter#42
  • Loading branch information
lucasdf committed Aug 9, 2017
1 parent 79374e2 commit 64afc63
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 0 deletions.
5 changes: 5 additions & 0 deletions coffeelint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"max_line_length": {
"level": "ignore"
}
}
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,21 @@
"description": "Linter plugin for pycodestyle",
"repository": "https://github.com/AtomLinter/linter-pycodestyle",
"license": "MIT",
"scripts": {
"test": "apm test",
"lint": "coffeelint ."
},
"engines": {
"atom": ">0.50.0"
},
"dependencies": {
"atom-linter": "^8.0.0",
"atom-package-deps": "^4.0.1"
},
"devDependencies": {
"jasmine-fix": "^1.0.1",
"coffeelint": "^1.9.7"
},
"package-deps": [
"linter"
],
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/bad.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import os, path
Empty file added spec/fixtures/empty.py
Empty file.
1 change: 1 addition & 0 deletions spec/fixtures/good.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Simple test file."""
56 changes: 56 additions & 0 deletions spec/linter-pycodestyle-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
'use babel';

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

const fixturePath = join(__dirname, 'fixtures');
const goodPath = join(fixturePath, 'good.py');
const badPath = join(fixturePath, 'bad.py');
const emptyPath = join(fixturePath, 'empty.py');

describe('The pycodestyle provider for Linter', () => {
const lint = require('../lib/main.coffee').provideLinter().lint;

beforeEach(async () => {
// Info about this beforeEach() implementation:
// https://github.com/AtomLinter/Meta/issues/15
const activationPromise = atom.packages.activatePackage('linter-pycodestyle');

await atom.packages.activatePackage('language-python');

atom.packages.triggerDeferredActivationHooks();
await activationPromise;
});

it('should be in the packages list', () =>
expect(atom.packages.isPackageLoaded('linter-pycodestyle')).toBe(true),
);

it('should be an active package', () =>
expect(atom.packages.isPackageActive('linter-pycodestyle')).toBe(true),
);

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

it('verifies that message', async () => {
const messages = await lint(editor);
expect(messages[0].type).toBe('Warning');
expect(messages[0].html).not.toBeDefined();
expect(messages[0].text).toBe(' E401 multiple imports on one line');
expect(messages[0].filePath).toBe(badPath);
expect(messages[0].range).toEqual([[0, 9], [0, 10]]);
});
});

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

});

0 comments on commit 64afc63

Please sign in to comment.