Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: replace migrate coffee unit tests to modern JS (#407)
- Loading branch information
1 parent
49f174d
commit 83bafc3
Showing
18 changed files
with
906 additions
and
790 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,3 +1,11 @@ | ||
{ | ||
"extends": "standard" | ||
"extends": "standard", | ||
"env": { | ||
"node": true, | ||
"mocha": true | ||
}, | ||
"globals": { | ||
"expect": true, | ||
"sinon": 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
This file was deleted.
Oops, something went wrong.
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,31 @@ | ||
const coverageMap = require('../lib/coverage-map') | ||
const coverageObj = { path: './path.js', otherThings: 'that are in instrumented code' } | ||
|
||
describe('coverageMap', () => { | ||
it('should add coverageMap and get them', () => { | ||
coverageMap.add(coverageObj) | ||
expect(coverageMap.get()['./path.js']).to.equal(coverageObj) | ||
}) | ||
|
||
it('should be able to be reset', () => { | ||
coverageMap.reset() | ||
|
||
expect(coverageMap.get()['./path.js']).to.not.exist | ||
|
||
coverageMap.add(coverageObj) | ||
|
||
expect(coverageMap.get()['./path.js']).to.equal(coverageObj) | ||
|
||
coverageMap.reset() | ||
|
||
expect(coverageMap.get()['./path.js']).to.not.exist | ||
}) | ||
|
||
it('should be able to have multiple coverageMap', () => { | ||
coverageMap.reset() | ||
coverageMap.add(coverageObj) | ||
coverageMap.add({ path: './anotherFile.js', moarKeys: [1, 2, 3] }) | ||
|
||
expect(Object.keys(coverageMap.get()).length).to.equal(2) | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
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,30 @@ | ||
const InMemoryReport = require('../lib/in-memory-report') | ||
|
||
describe('InMemoryReport', () => { | ||
const emitter = {emit: sinon.stub()} | ||
const browser = { name: 'firefox' } | ||
const result = { test: { data: 'result' } } | ||
const fc = { | ||
path: 'test', | ||
toJSON: sinon.stub().returns({ data: 'result' }) | ||
} | ||
const node = {getFileCoverage: sinon.stub().returns(fc)} | ||
|
||
it('should raise an "coverage_complete" event.', () => { | ||
const sut = new InMemoryReport({browser, emitter}) | ||
sut.onStart() | ||
sut.onDetail(node) | ||
sut.onEnd() | ||
expect(node.getFileCoverage).to.have.been.called | ||
expect(fc.toJSON).to.have.been.called | ||
expect(emitter.emit).to.have.been.calledWith('coverage_complete', browser, result) | ||
}) | ||
|
||
it('should be of type "in-memory"', () => | ||
expect(InMemoryReport.TYPE).to.be.equal('in-memory') | ||
) | ||
|
||
it('should not fail when created without arguments', () => | ||
expect(new InMemoryReport()).to.be.ok | ||
) | ||
}) |
This file was deleted.
Oops, something went wrong.
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,9 @@ | ||
require('../lib/index') | ||
const InMemoryReport = require('../lib/in-memory-report') | ||
const reportCreator = require('../lib/report-creator') | ||
|
||
describe('Index', () => { | ||
it('should register "InMemoryReport" to Report Creator', () => | ||
expect(reportCreator.create('in-memory', {})).to.be.an.instanceof(InMemoryReport) | ||
) | ||
}) |
This file was deleted.
Oops, something went wrong.
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,12 @@ | ||
const sinon = require('sinon') | ||
const chai = require('chai') | ||
|
||
// publish globals that all specs can use | ||
global.expect = chai.expect | ||
global.should = chai.should() | ||
global.sinon = sinon | ||
|
||
// chai plugins | ||
chai.use(require('sinon-chai')) | ||
|
||
afterEach(() => global.sinon.restore()) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.