This repository has been archived by the owner on Feb 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kelly Selden
committed
Jan 9, 2016
1 parent
fbb6d27
commit 6dfdde9
Showing
3 changed files
with
96 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import path from 'path'; | ||
|
||
const testFile = path.resolve(__dirname, 'test-file.js'); | ||
|
||
export default options => { | ||
let { eslintFiles } = options; | ||
|
||
process.env.NODE_ESLINT_FILES = eslintFiles.join(','); | ||
|
||
let testFile = path.resolve(__dirname, 'test-file.js'); | ||
|
||
return testFile; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { expect } from 'chai'; | ||
import sinon from 'sinon'; | ||
import initialize from '../../../lib/eslint/initialize'; | ||
|
||
describe.only('unit - eslint/initialize', function() { | ||
let env; | ||
|
||
beforeEach(function() { | ||
env = process.env.NODE_ESLINT_FILES; | ||
process.env.NODE_ESLINT_FILES = ''; | ||
|
||
initialize.__Rewire__('path', { | ||
resolve: sinon.stub() | ||
}); | ||
}); | ||
|
||
afterEach(function() { | ||
process.env.NODE_ESLINT_FILES = env; | ||
|
||
initialize.__ResetDependency__('path'); | ||
}); | ||
|
||
it('sets environment variable', function() { | ||
initialize({ | ||
eslintFiles: ['test-file-1', 'test-file-2'] | ||
}); | ||
|
||
expect(process.env.NODE_ESLINT_FILES).to.equal('test-file-1,test-file-2'); | ||
}); | ||
|
||
it('returns test file path', function() { | ||
initialize.__Rewire__('path', { | ||
resolve: sinon.stub().returns('resolved-test-path') | ||
}); | ||
|
||
let testFile = initialize({ | ||
eslintFiles: [] | ||
}); | ||
|
||
expect(testFile).to.equal('resolved-test-path'); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { expect } from 'chai'; | ||
import sinon from 'sinon'; | ||
import Mocha from 'mocha'; | ||
import run from '../../../lib/mocha/run'; | ||
|
||
describe('unit - mocha/run', function() { | ||
beforeEach(function() { | ||
run.__Rewire__('addCompilers', sinon.stub()); | ||
run.__Rewire__('addFiles', sinon.stub()); | ||
}); | ||
|
||
afterEach(function() { | ||
run.__ResetDependency__('addCompilers'); | ||
run.__ResetDependency__('addFiles'); | ||
}); | ||
|
||
it('calls addCompilers correctly', function() { | ||
let addCompilers = sinon.stub(); | ||
run.__Rewire__('addCompilers', addCompilers); | ||
|
||
run(null, { | ||
mochaCompilers: ['test-compilers'] | ||
}); | ||
|
||
expect(addCompilers.args).to.deep.equal([ | ||
[['test-compilers'], ['js']] | ||
]); | ||
}); | ||
|
||
it('calls addFiles correctly', function() { | ||
let addFiles = sinon.stub(); | ||
run.__Rewire__('addFiles', addFiles); | ||
|
||
run.__Rewire__('addCompilers', (mochaCompilers, extensions) => { | ||
extensions.pop(); | ||
extensions.push('test-ext'); | ||
}); | ||
|
||
run('lint-test-file', { | ||
mochaFiles: ['mocha-file-test'], | ||
isMochaRecursive: true | ||
}); | ||
|
||
expect(addFiles.callCount).to.equal(1); | ||
let call = addFiles.getCall(0); | ||
expect(call.args[0]).to.be.an.instanceof(Mocha); | ||
expect(call.args[1]).to.deep.equal(['mocha-file-test']); | ||
expect(call.args[2]).to.deep.equal(['test-ext']); | ||
expect(call.args[3]).to.be.true; | ||
expect(call.args[4]).to.equal('lint-test-file'); | ||
}); | ||
}); |