Skip to content
This repository has been archived by the owner on Jul 29, 2019. It is now read-only.

Commit

Permalink
Add unit tests for Graph3D issue (#3260)
Browse files Browse the repository at this point in the history
* Add unit tests for Graph3D issue

This adds a unit test for PR #3255 which fixes #3251.
The unit test will fail without the PR merged.

**NOTE:** This also adds module `canvas`, required for the unit test. This module
proved to be quite fickly to install properly. During reviewing, please pay special
attention to the proper installation of this modul. I.e. do following to test:

```
> npm install                      # If no errors, continue
> npm test /tests/Graph3D.test.js  # Run unit test isolated
```

* Fix for travis-cl

* Add giflib to travis test definition

* Add libgif to travis test definition - take 2

* Proper setup and teardown for jsdom-global

* Minor fixes and cleanup
  • Loading branch information
wimrijnders authored and yotamberk committed Jul 20, 2017
1 parent af4e1fa commit ca6beb0
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions test/Graph3d.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
var assert = require('assert');
var jsdom_global = require('jsdom-global');
var vis = require('../dist/vis');
var Graph3d = vis.Graph3d;


describe('Graph3d', function () {

before(function() {
//console.log('before!');
this.jsdom_global = jsdom_global(
"<div id='mynetwork'></div>",
{ skipWindowCheck: true}
);
this.container = document.getElementById('mynetwork');
});

it('accepts new option values on defined instance', function () {
assert(this.container !== null, 'Container div not found');

var BAR_STYLE = 0; // from var STYLE in Settings.js
var DOT_STYLE = 3; // idem

var data = [
{x:0, y:0, z: 10},
{x:0, y:1, z: 20},
{x:1, y:0, z: 30},
{x:1, y:1, z: 40},
];

var options = {
style: 'dot'
};

var graph = new vis.Graph3d(this.container, data, options);
assert.equal(graph.style, DOT_STYLE, "Style not set to expected 'dot'");

graph.setOptions({ style: 'bar'}); // Call should just work, no exception thrown
assert.equal(graph.style, BAR_STYLE, "Style not set to expected 'bar'");
});


after(function() {
//console.log('after!');
this.jsdom_global();
});
});

0 comments on commit ca6beb0

Please sign in to comment.