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

Add basic specs #115

Merged
merged 2 commits into from
Sep 26, 2016
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
46 changes: 38 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,41 @@
language: node_js
node_js:
- "4.1"
env:
- CXX=g++-4.8
### Project specific config ###
language: generic

matrix:
include:
- os: linux
env: ATOM_CHANNEL=stable

- os: linux
env: ATOM_CHANNEL=beta

- os: osx
env: ATOM_CHANNEL=stable

### Generic setup follows ###
script:
- curl -s -O https://raw.githubusercontent.com/atom/ci/master/build-package.sh
- chmod u+x build-package.sh
- ./build-package.sh

notifications:
email:
on_success: never
on_failure: change

branches:
only:
- master

git:
depth: 10

sudo: false

addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8
- build-essential
- git
- libgnome-keyring-dev
- fakeroot
31 changes: 28 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"url": "https://github.com/AtomLinter/linter-tslint.git"
},
"scripts": {
"test": "npm run lint",
"lint": "coffeelint ./lib"
"test": "apm test",
"lint": "coffeelint lib && eslint ."
},
"license": "MIT",
"engines": {
Expand Down Expand Up @@ -42,6 +42,31 @@
}
},
"devDependencies": {
"coffeelint": "1.15.7"
"coffeelint": "1.15.7",
"eslint": "^3.6.0",
"eslint-config-airbnb-base": "^8.0.0",
"eslint-plugin-import": "^1.16.0"
},
"eslintConfig": {
"extends": "airbnb-base",
"rules": {
"global-require": "off",
"import/no-unresolved": [
"error",
{
"ignore": [
"atom"
]
}
]
},
"env": {
"es6": true,
"browser": true,
"node": true
},
"globals": {
"atom": true
}
}
}
6 changes: 6 additions & 0 deletions spec/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
env: {
jasmine: true,
atomtest: true
}
};
2 changes: 2 additions & 0 deletions spec/fixtures/invalid/invalid.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const foo = 42
export default foo;
7 changes: 7 additions & 0 deletions spec/fixtures/invalid/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"compileOnSave": false,
"buildOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}
5 changes: 5 additions & 0 deletions spec/fixtures/invalid/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"semicolon": true
}
}
7 changes: 7 additions & 0 deletions spec/fixtures/valid/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"compileOnSave": false,
"buildOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}
5 changes: 5 additions & 0 deletions spec/fixtures/valid/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"semicolon": true
}
}
2 changes: 2 additions & 0 deletions spec/fixtures/valid/valid.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const foo = 42;
export default foo;
42 changes: 42 additions & 0 deletions spec/linter-tslint-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'use babel';

import * as path from 'path';

const validPath = path.join(__dirname, 'fixtures', 'valid', 'valid.ts');
const invalidPath = path.join(__dirname, 'fixtures', 'invalid', 'invalid.ts');

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

beforeEach(() => {
atom.workspace.destroyActivePaneItem();

waitsForPromise(() =>
Promise.all([
atom.packages.activatePackage('linter-tslint'),
])
);
});

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

it('handles messages from TSLint', () => {
const expectedMsg = 'semicolon - Missing semicolon';
waitsForPromise(() =>
atom.workspace.open(invalidPath).then(editor => lint(editor)).then((messages) => {
expect(messages.length).toBe(1);
expect(messages[0].type).toBe('Warning');
expect(messages[0].html).not.toBeDefined();
expect(messages[0].text).toBe(expectedMsg);
expect(messages[0].filePath).toBe(invalidPath);
expect(messages[0].range).toEqual([[0, 14], [0, 14]]);
})
);
});
});