This repository has been archived by the owner on Jul 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding unit tests for lib/shared (#3600)
* Adds code coverage report the output of `npm test` and adds detailed html code coverage report using the command `npm run-script test-cov` * Switch over to using functions in lib/ rather than dist/, so that code coverage stats are complete. * Import vis at the top level to keep ItemSet passing * Remove requirement for dist/vis in TimelineItemSet * Adds tests for Popup * Tests and sinon dependency introduced * Code changes to modules to tighten up code * Corrects broken tests and adds more tests to ColorPicker * Adds additional tests to DataSet * Adds tests for uuid * Removes unused functions from util * Adds tests for utils: recursiveDomDelete, isDate, convert and isType * removes redundant code * Adds additional util tests * Address spacing, and unnecessary tests * Correct test description * Adds isDate tests * Adds sanity check assertions to popup destroy tests
- Loading branch information
1 parent
95657e9
commit fb6872d
Showing
13 changed files
with
1,177 additions
and
68 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
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,90 @@ | ||
var assert = require('assert'); | ||
var sinon = require('sinon'); | ||
var jsdom = require('jsdom'); | ||
var jsdom_global = require('jsdom-global'); | ||
|
||
|
||
var canvasMockify = require('./canvas-mock'); | ||
var Activator = require('../lib/shared/Activator'); | ||
|
||
|
||
describe('Activator', function () { | ||
beforeEach(function() { | ||
this.jsdom_global = canvasMockify("<div id='mynetwork'></div>"); | ||
this.container = document.getElementById('mynetwork'); | ||
}); | ||
|
||
afterEach(function() { | ||
this.jsdom_global(); | ||
this.container.remove(); | ||
this.container = undefined; | ||
}); | ||
|
||
describe('constructor', function () { | ||
|
||
it('sets defaults', function () { | ||
var activator = new Activator(this.container); | ||
assert.equal(activator.active, false); | ||
}); | ||
|
||
it('creates overlay', function () { | ||
var activator = new Activator(this.container); | ||
assert.equal(activator.dom.container.children[0].className, 'vis-overlay'); | ||
}); | ||
}); | ||
|
||
describe('activate', function () { | ||
it('emits an `activate` event', function () { | ||
var eventSpy = sinon.spy(); | ||
var activator = new Activator(this.container); | ||
activator.on('activate', eventSpy); | ||
activator.activate(); | ||
assert.equal(activator.active, true); | ||
assert(eventSpy.called, 'Event did not fire.'); | ||
assert(eventSpy.calledOnce, 'Event fired more than once'); | ||
}); | ||
|
||
it('emits a `change` event', function () { | ||
var eventSpy = sinon.spy(); | ||
var activator = new Activator(this.container); | ||
activator.on('change', eventSpy); | ||
activator.activate(); | ||
assert.equal(activator.active, true); | ||
assert(eventSpy.called, 'Event did not fire.'); | ||
assert(eventSpy.calledOnce, 'Event fired more than once'); | ||
}); | ||
}); | ||
|
||
describe('deactivate', function () { | ||
it('emits a `deactivate` event', function () { | ||
var eventSpy = sinon.spy(); | ||
var activator = new Activator(this.container); | ||
activator.on('deactivate', eventSpy); | ||
activator.deactivate(); | ||
assert.equal(activator.active, false); | ||
assert(eventSpy.called, 'Event did not fire.'); | ||
assert(eventSpy.calledOnce, 'Event fired more than once'); | ||
}); | ||
|
||
it('emits a `change` event', function () { | ||
var eventSpy = sinon.spy(); | ||
var activator = new Activator(this.container); | ||
activator.on('change', eventSpy); | ||
activator.deactivate(); | ||
assert.equal(activator.active, false); | ||
assert(eventSpy.called, 'Event did not fire.'); | ||
assert(eventSpy.calledOnce, 'Event fired more than once'); | ||
}); | ||
}); | ||
|
||
describe('destroy', function () { | ||
|
||
it('sets inactive, removes keycharm, and removes hammer', function () { | ||
var activator = new Activator(this.container); | ||
activator.destroy(); | ||
assert.equal(activator.active, false); | ||
assert.equal(activator.keycharm, null); | ||
assert.equal(activator.hammer, null); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.