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

Commit

Permalink
Add specs
Browse files Browse the repository at this point in the history
  • Loading branch information
Arcanemagus committed Dec 11, 2015
1 parent 610c695 commit d0f8a6c
Show file tree
Hide file tree
Showing 7 changed files with 173 additions and 39 deletions.
38 changes: 0 additions & 38 deletions coffeelint.json

This file was deleted.

55 changes: 54 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,67 @@
"atom-package-deps": "^3.0.6"
},
"devDependencies": {
"coffeelint": "^1.12.1"
"coffeelint": "^1.14.1",
"eslint": "^1.10.3",
"babel-eslint": "^4.1.5",
"eslint-config-airbnb": "^2.0.0"
},
"package-deps": [
"linter"
],
"scripts": {
"lint": "./node_modules/.bin/coffeelint lib"
},
"eslintConfig": {
"extends": "airbnb/base",
"parser": "babel-eslint",
"globals": {
"atom": true,
"waitsForPromise": true
},
"env": {
"es6": true,
"node": true
}
},
"coffeelintConfig": {
"max_line_length": {
"value": 120,
"level": "warn"
},
"no_empty_param_list": {
"level": "error"
},
"arrow_spacing": {
"level": "error"
},
"no_interpolation_in_single_quotes": {
"level": "error"
},
"no_debugger": {
"level": "error"
},
"prefer_english_operator": {
"level": "error"
},
"colon_assignment_spacing": {
"spacing": {
"left": 0,
"right": 1
},
"level": "error"
},
"braces_spacing": {
"spaces": 0,
"level": "error"
},
"spacing_after_comma": {
"level": "error"
},
"no_stand_alone_at": {
"level": "error"
}
},
"providedServices": {
"linter": {
"versions": {
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/bad.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.div {}
Empty file added spec/fixtures/empty.css
Empty file.
3 changes: 3 additions & 0 deletions spec/fixtures/good.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.div {
color: blue;
}
1 change: 1 addition & 0 deletions spec/fixtures/invalid.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
}
114 changes: 114 additions & 0 deletions spec/linter-csslint-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
'use babel';
/* eslint-env jasmine */

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

beforeEach(() => {
atom.workspace.destroyActivePaneItem();
waitsForPromise(() => {
atom.packages.activatePackage('linter-csslint');
return atom.packages.activatePackage('language-css').then(() =>
atom.workspace.open(__dirname + '/fixtures/empty.css')
);
});
});

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

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

describe('checks bad.css and', () => {
let editor = null;
beforeEach(() => {
waitsForPromise(() => {
return atom.workspace.open(__dirname + '/fixtures/bad.css').then(openEditor => {
editor = openEditor;
});
});
});

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

it('verifies the first message', () => {
waitsForPromise(() => {
return lint(editor).then(messages => {
expect(messages[0].type).toBeDefined();
expect(messages[0].type).toEqual('Warning');
expect(messages[0].text).toBeDefined();
expect(messages[0].text).toEqual('Rule is empty.');
expect(messages[0].filePath).toBeDefined();
expect(messages[0].filePath).toMatch(/.+bad\.css$/);
expect(messages[0].range).toBeDefined();
expect(messages[0].range.length).toEqual(2);
expect(messages[0].range).toEqual([[0, 0], [0, 0]]);
});
});
});
});

describe('warns on invalid CSS', () => {
let editor = null;
beforeEach(() => {
waitsForPromise(() => {
return atom.workspace.open(__dirname + '/fixtures/invalid.css').then(openEditor => {
editor = openEditor;
});
});
});

it('finds one message', () => {
waitsForPromise(() => {
return lint(editor).then(messages => {
expect(messages.length).toBe(1);
});
});
});

it('verifies the message', () => {
waitsForPromise(() => {
return lint(editor).then(messages => {
expect(messages[0].type).toBeDefined();
expect(messages[0].type).toEqual('Error');
expect(messages[0].text).toBeDefined();
expect(messages[0].text).toEqual('Unexpected token \'}\' at line 1, col 1.');
expect(messages[0].filePath).toBeDefined();
expect(messages[0].filePath).toMatch(/.+invalid\.css$/);
expect(messages[0].range).toBeDefined();
expect(messages[0].range.length).toEqual(2);
expect(messages[0].range).toEqual([[0, 0], [0, 0]]);
});
});
});
});

it('finds nothing wrong with an empty file', () => {
waitsForPromise(() => {
return atom.workspace.open(__dirname + '/fixtures/empty.css').then(editor => {
return lint(editor).then(messages => {
expect(messages.length).toEqual(0);
});
});
});
});

it('finds nothing wrong with a valid file', () => {
waitsForPromise(() => {
return atom.workspace.open(__dirname + '/fixtures/good.css').then(editor => {
return lint(editor).then(messages => {
expect(messages.length).toEqual(0);
});
});
});
});
});

0 comments on commit d0f8a6c

Please sign in to comment.