This repository has been archived by the owner on Aug 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #111 from AtomLinter/greenkeeper-atom-linter-4.3.4
- Loading branch information
Showing
3 changed files
with
81 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,86 @@ | ||
'use babel'; | ||
|
||
import * as path from 'path'; | ||
|
||
const goodPath = path.join(__dirname, 'files', 'good.py'); | ||
const badPath = path.join(__dirname, 'files', 'bad.py'); | ||
const emptyPath = path.join(__dirname, 'files', 'empty.py'); | ||
|
||
describe('The pylint provider for Linter', () => { | ||
const lint = require('../lib/main').provideLinter().lint; | ||
|
||
beforeEach(() => { | ||
waitsForPromise(() => { | ||
return Promise.all([ | ||
waitsForPromise(() => | ||
Promise.all([ | ||
atom.packages.activatePackage('linter-pylint'), | ||
atom.packages.activatePackage('language-python').then(() => | ||
atom.workspace.open(__dirname + '/files/good.py') | ||
atom.workspace.open(goodPath) | ||
) | ||
]); | ||
}); | ||
]) | ||
); | ||
}); | ||
|
||
it('should be in the packages list', () => { | ||
return expect(atom.packages.isPackageLoaded('linter-pylint')).toBe(true); | ||
}); | ||
it('should be in the packages list', () => | ||
expect(atom.packages.isPackageLoaded('linter-pylint')).toBe(true) | ||
); | ||
|
||
it('should be an active package', () => { | ||
return expect(atom.packages.isPackageActive('linter-pylint')).toBe(true); | ||
}); | ||
it('should be an active package', () => | ||
expect(atom.packages.isPackageActive('linter-pylint')).toBe(true) | ||
); | ||
|
||
describe('checks bad.py and', () => { | ||
let editor = null; | ||
beforeEach(() => { | ||
waitsForPromise(() => { | ||
return atom.workspace.open(__dirname + '/files/bad.py').then(openEditor => { | ||
waitsForPromise(() => | ||
atom.workspace.open(badPath).then(openEditor => { | ||
editor = openEditor; | ||
}); | ||
}); | ||
}) | ||
); | ||
}); | ||
|
||
it('finds at least one message', () => { | ||
return lint(editor).then(messages => { | ||
expect(messages.length).toBeGreaterThan(0); | ||
}); | ||
}); | ||
it('finds at least one message', () => | ||
waitsForPromise(() => | ||
lint(editor).then(messages => { | ||
expect(messages.length).toBeGreaterThan(0); | ||
}) | ||
) | ||
); | ||
|
||
it('verifies that message', () => { | ||
return lint(editor).then(messages => { | ||
expect(messages[0].type).toBeDefined(); | ||
expect(messages[0].type).toEqual('convention'); | ||
expect(messages[0].html).not.toBeDefined(); | ||
expect(messages[0].text).toBeDefined(); | ||
expect(messages[0].text).toEqual('C0111 Missing module docstring'); | ||
expect(messages[0].filePath).toBeDefined(); | ||
expect(messages[0].filePath).toMatch(/.+spec[\\\/]files[\\\/]bad\.py$/); | ||
expect(messages[0].range).toBeDefined(); | ||
expect(messages[0].range.length).toEqual(2); | ||
expect(messages[0].range).toEqual([[0, 0], [0, 4]]); | ||
}); | ||
}); | ||
it('verifies that message', () => | ||
waitsForPromise(() => | ||
lint(editor).then(messages => { | ||
expect(messages[0].type).toBeDefined(); | ||
expect(messages[0].type).toEqual('convention'); | ||
expect(messages[0].html).not.toBeDefined(); | ||
expect(messages[0].text).toBeDefined(); | ||
expect(messages[0].text).toEqual('C0111 Missing module docstring'); | ||
expect(messages[0].filePath).toBeDefined(); | ||
expect(messages[0].filePath).toMatch(/.+spec[\\\/]files[\\\/]bad\.py$/); | ||
expect(messages[0].range).toBeDefined(); | ||
expect(messages[0].range.length).toEqual(2); | ||
expect(messages[0].range).toEqual([[0, 0], [0, 4]]); | ||
}) | ||
) | ||
); | ||
}); | ||
|
||
it('finds nothing wrong with an empty file', () => { | ||
waitsForPromise(() => { | ||
return atom.workspace.open(__dirname + '/files/empty.py').then(editor => { | ||
return lint(editor).then(messages => { | ||
waitsForPromise(() => | ||
atom.workspace.open(emptyPath).then(editor => | ||
lint(editor).then(messages => { | ||
expect(messages.length).toEqual(0); | ||
}); | ||
}); | ||
}); | ||
}) | ||
) | ||
); | ||
}); | ||
|
||
it('finds nothing wrong with a valid file', () => { | ||
waitsForPromise(() => { | ||
return atom.workspace.open(__dirname + '/files/good.py').then(editor => { | ||
return lint(editor).then(messages => { | ||
waitsForPromise(() => | ||
atom.workspace.open(goodPath).then(editor => | ||
lint(editor).then(messages => { | ||
expect(messages.length).toEqual(0); | ||
}); | ||
}); | ||
}); | ||
}) | ||
) | ||
); | ||
}); | ||
}); |