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
4cf7b4f
commit a4ff2e8
Showing
6 changed files
with
103 additions
and
13 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,4 +1,4 @@ | ||
{ | ||
"presets": ["es2015", "stage-2"], | ||
"plugins": [] | ||
"plugins": ["rewire"] | ||
} |
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
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,22 +1,45 @@ | ||
import { expect } from 'chai'; | ||
import addCompilers from '../../../lib/mocha/add-compilers'; | ||
|
||
describe('unit - addCompilers', function() { | ||
it('pushes to extentsions', function() { | ||
let compilers = ['js:babel-register']; | ||
describe('unit - mocha/addCompilers', function() { | ||
beforeEach(function() { | ||
addCompilers.__Rewire__('_require', () => {}); | ||
}); | ||
|
||
afterEach(function() { | ||
addCompilers.__ResetDependency__('_require'); | ||
}); | ||
|
||
it('pushes to extensions', function() { | ||
let compilers = ['test-ext:']; | ||
let extensions = []; | ||
|
||
addCompilers(compilers, extensions); | ||
|
||
expect(extensions).to.deep.equal(['js']); | ||
expect(extensions).to.deep.equal(['test-ext']); | ||
}); | ||
|
||
it('does not duplicate extensions', function() { | ||
let compilers = ['js:babel-register']; | ||
let extensions = ['js']; | ||
let compilers = ['test-ext:']; | ||
let extensions = ['test-ext']; | ||
|
||
addCompilers(compilers, extensions); | ||
|
||
expect(extensions).to.deep.equal(['test-ext']); | ||
}); | ||
|
||
it('calls require with module name', function() { | ||
let compilers = [':test-mod']; | ||
let extensions = []; | ||
|
||
let wasCalled; | ||
addCompilers.__Rewire__('_require', module => { | ||
expect(module).to.equal('test-mod'); | ||
wasCalled = true; | ||
}); | ||
|
||
addCompilers(compilers, extensions); | ||
|
||
expect(extensions).to.deep.equal(['js']); | ||
expect(wasCalled).to.be.true; | ||
}); | ||
}); |
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,63 @@ | ||
import { expect } from 'chai'; | ||
import sinon from 'sinon'; | ||
import addFiles from '../../../lib/mocha/add-files'; | ||
|
||
describe('unit - mocha/addFiles', function() { | ||
beforeEach(function() { | ||
addFiles.__Rewire__('utils', { | ||
lookupFiles(file) { return [file]; } | ||
}); | ||
}); | ||
|
||
afterEach(function() { | ||
addFiles.__ResetDependency__('utils'); | ||
}); | ||
|
||
it('calls lookupFiles correctly', function() { | ||
let mocha = { | ||
addFile: sinon.stub() | ||
}; | ||
let files = ['test-file-1', 'test-file-2']; | ||
|
||
let lookupFilesStub = sinon.stub().returns([]); | ||
addFiles.__Rewire__('utils', { | ||
lookupFiles: lookupFilesStub | ||
}); | ||
|
||
addFiles(mocha, files, ['test-extension'], true, null); | ||
|
||
expect(lookupFilesStub.callCount).to.equal(2); | ||
expect(lookupFilesStub.args).to.deep.equal([ | ||
['test-file-1', ['test-extension'], true], | ||
['test-file-2', ['test-extension'], true] | ||
]); | ||
}); | ||
|
||
it('adds "test" if nothing supplied', function() { | ||
let addFileStub = sinon.stub(); | ||
let mocha = { | ||
addFile: addFileStub | ||
}; | ||
let files = []; | ||
|
||
addFiles(mocha, files, null, null, 'lint-test-file'); | ||
|
||
expect(addFileStub.callCount).to.equal(2); | ||
expect(addFileStub.thisValues).to.deep.equal([mocha, mocha]); | ||
expect(addFileStub.args).to.deep.equal([['test'], ['lint-test-file']]); | ||
}); | ||
|
||
it('does not add "test" twice', function() { | ||
let addFileStub = sinon.stub(); | ||
let mocha = { | ||
addFile: addFileStub | ||
}; | ||
let files = ['test']; | ||
|
||
addFiles(mocha, files, null, null, 'lint-test-file'); | ||
|
||
expect(addFileStub.callCount).to.equal(2); | ||
expect(addFileStub.thisValues).to.deep.equal([mocha, mocha]); | ||
expect(addFileStub.args).to.deep.equal([['test'], ['lint-test-file']]); | ||
}); | ||
}); |