-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved API to make config optional
Added tests for TestRunner
- Loading branch information
1 parent
9fbbc9d
commit fe3f38a
Showing
4 changed files
with
75 additions
and
7 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
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,62 @@ | ||
'use strict'; | ||
|
||
const expect = require('chai').expect, | ||
sinon = require('sinon'); | ||
|
||
const TestRunner = require('./TestRunner'), | ||
TestConfig = require('./TestConfig'), | ||
TestSuite = require('./TestSuite'); | ||
|
||
describe('TestRunner', () => { | ||
|
||
describe('run', () => { | ||
|
||
let testStubs, | ||
config, def, configStub; | ||
|
||
beforeEach(() => { | ||
testStubs = []; | ||
config = {config: 123}; | ||
def = {def: 123}; | ||
configStub = 'configStub'; | ||
|
||
sinon.stub(TestSuite, 'generate').callsFake(() => testStubs); | ||
sinon.stub(TestConfig, 'make').returns(configStub); | ||
}); | ||
|
||
afterEach(() => { | ||
TestSuite.generate.restore(); | ||
TestConfig.make.restore(); | ||
}); | ||
|
||
it('calls generate with test suite and config', () => { | ||
TestRunner.run('app', config, def); | ||
|
||
expect(TestSuite.generate.calledOnce).to.be.true; | ||
expect(TestSuite.generate.calledWithExactly(def, configStub)).to.be.true; | ||
}); | ||
|
||
it('calls generate with test suite and default config', () => { | ||
TestRunner.run('app', def); | ||
|
||
expect(TestSuite.generate.calledOnce).to.be.true; | ||
expect(TestSuite.generate.calledWithExactly(def, configStub)).to.be.true; | ||
}); | ||
|
||
it('calls run(app) on every generated test suites', () => { | ||
testStubs = [ | ||
{run: sinon.spy()}, | ||
{run: sinon.spy()} | ||
]; | ||
|
||
TestRunner.run('app', config, def); | ||
|
||
testStubs.forEach(stub => { | ||
expect(stub.run.calledOnce).to.be.true; | ||
expect(stub.run.calledWithExactly('app')).to.be.true; | ||
}); | ||
}); | ||
|
||
}); | ||
|
||
}); |