From b00966c4525ba7b76c42983b0affcf5b2dd16ad5 Mon Sep 17 00:00:00 2001 From: etpinard Date: Mon, 30 Nov 2015 13:34:27 -0500 Subject: [PATCH 01/10] clean up some comments --- circle.yml | 10 +++++----- tasks/baseline.sh | 17 +++-------------- tasks/test_image.sh | 17 +++-------------- test/image/README.md | 5 ++++- 4 files changed, 15 insertions(+), 34 deletions(-) diff --git a/circle.yml b/circle.yml index a9a93cf0840..2615242402e 100644 --- a/circle.yml +++ b/circle.yml @@ -1,17 +1,17 @@ general: artifacts: - - "build/test_images/" # relative to the build directory - - "build/test_images_diff/" # relative to the build directory + - "build/test_images/" + - "build/test_images_diff/" machine: node: - version: 4.2.1 + version: 4.2.1 services: - docker - + dependencies: - pre: + pre: - docker pull plotly/imageserver:latest post: - npm run cibuild diff --git a/tasks/baseline.sh b/tasks/baseline.sh index 02396268504..3b60509bc27 100755 --- a/tasks/baseline.sh +++ b/tasks/baseline.sh @@ -2,23 +2,12 @@ # # TODO adapt this for Windows # -# TODO add package.json config arguments to configure: -# - container name, -# - ports and -# - imageserver version -# # =============================================================================== -CONTAINER_NAME="imagetest" -IMAGE_NAME="registry.plot.ly:5000/imageserver" -IMAGE_VERSION="1.3.0" +CONTAINER_NAME="imagetest" # same as in docker-compose.yml -# Run docker container: -# -# docker run -d --name $CONTAINER_NAME \ -# -v $PWD/plotly.js:/var/www/streambed/image_server/plotly.js \ -# -p 9010:9010 -p 2022:22 \ -# $IMAGE_NAME:[$IMAGE_VERSION] +# create/run/start docker container with: +# $ docker-compose up -d CMD=( "cd /var/www/streambed/image_server/plotly.js &&" diff --git a/tasks/test_image.sh b/tasks/test_image.sh index 9dee5295017..d4f3de554a5 100755 --- a/tasks/test_image.sh +++ b/tasks/test_image.sh @@ -2,23 +2,12 @@ # # TODO adapt this for Windows # -# TODO add package.json config arguments to configure: -# - container name, -# - ports and -# - imageserver version -# # =============================================================================== -CONTAINER_NAME="imagetest" -IMAGE_NAME="registry.plot.ly:5000/imageserver" -IMAGE_VERSION="1.3.0" +CONTAINER_NAME="imagetest" # same as in docker-compose.yml -# Run docker container: -# -# docker run -d --name $CONTAINER_NAME \ -# -v $PWD/plotly.js:/var/www/streambed/image_server/plotly.js \ -# -p 9010:9010 -p 2022:22 \ -# $IMAGE_NAME:[$IMAGE_VERSION] +# create/run/start docker container with: +# $ docker-compose up -d CMD=( "cd /var/www/streambed/image_server/plotly.js &&" diff --git a/test/image/README.md b/test/image/README.md index a8afc9861cf..02851f5fa37 100644 --- a/test/image/README.md +++ b/test/image/README.md @@ -71,6 +71,9 @@ docker images docker ps -a ``` +whereas `docker ps` lists only the started containers. + + ### Stop your testing container Inside your `plotly.js` directory, run @@ -87,4 +90,4 @@ Inside your `plotly.js` directory, run docker-compose rm -f ``` -For more comprehensive information about docker, please refer to [docker document](http://docs.docker.com/) +For more comprehensive information about docker, please refer to the [docker docs](http://docs.docker.com/). From 3b0e6aba9f871231f783c8f1b9b54a7c474fa0c9 Mon Sep 17 00:00:00 2001 From: etpinard Date: Mon, 30 Nov 2015 13:41:57 -0500 Subject: [PATCH 02/10] skip over gl3d_bunny-hull in pixel comparison test: - this test outputs random pixel from run-to-run, skip for now. --- test/image/compare_pixels_test.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/image/compare_pixels_test.js b/test/image/compare_pixels_test.js index f709cde767b..5c4b2e9c008 100644 --- a/test/image/compare_pixels_test.js +++ b/test/image/compare_pixels_test.js @@ -31,7 +31,8 @@ function runAll () { // -1 for font-wishlist and // -38 for the gl2d mocks - t.plan(files.length - 39); + // -1 for gl3d_bunny-hull + t.plan(files.length - 40); for (var i = 0; i < files.length; i ++) { testMock(files[i], t); @@ -54,6 +55,9 @@ function testMock (fileName, t) { // TODO fix race condition in gl2d image generation if(fileName.indexOf('gl2d_') !== -1) return; + // TODO fix run-to-run randomness + if(fileName === 'gl3d_bunny-hull.json') return; + var figure = require(path.join(constants.pathToTestImageMocks, fileName)); var bodyMock = { figure: figure, From 1dc2a017cb350352ec67f6dd72778ff7ec6c8937 Mon Sep 17 00:00:00 2001 From: etpinard Date: Mon, 30 Nov 2015 13:42:15 -0500 Subject: [PATCH 03/10] clean up compare pixel test logs --- test/image/compare_pixels_test.js | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/test/image/compare_pixels_test.js b/test/image/compare_pixels_test.js index 5c4b2e9c008..9de32789902 100644 --- a/test/image/compare_pixels_test.js +++ b/test/image/compare_pixels_test.js @@ -26,7 +26,6 @@ else runSingle(userFileName); function runAll () { test('testing mocks', function (t) { - console.error('### beginning pixel comparison tests ###'); var files = fs.readdirSync(constants.pathToTestImageMocks); // -1 for font-wishlist and @@ -70,7 +69,6 @@ function testMock (fileName, t) { var diffPath = path.join(constants.pathToTestImagesDiff, 'diff-' + imageFileName); var savedImageStream = fs.createWriteStream(savedImagePath); var options = getOptions(bodyMock, 'http://localhost:9010/'); - var statusCode; function checkImage () { var options = { @@ -79,17 +77,12 @@ function testMock (fileName, t) { tolerance: 0.0 }; - if(statusCode === 485) { - console.error(imageFileName, '- skip'); - } - else { - gm.compare( - savedImagePath, - path.join(constants.pathToTestImageBaselines, imageFileName), - options, - onEqualityCheck - ); - } + gm.compare( + savedImagePath, + path.join(constants.pathToTestImageBaselines, imageFileName), + options, + onEqualityCheck + ); } function onEqualityCheck (err, isEqual) { @@ -99,16 +92,12 @@ function testMock (fileName, t) { } if (isEqual) { fs.unlinkSync(diffPath); - console.error(imageFileName + ' is pixel perfect'); } - t.ok(isEqual, savedImagePath + ' should be pixel perfect'); + t.ok(isEqual, imageFileName + ' should be pixel perfect'); } request(options) - .on('response', function(response) { - statusCode = response.statusCode; - }) .pipe(savedImageStream) .on('close', checkImage); } From a466517baed18194cc7f6d20d08be0d68af9dc6e Mon Sep 17 00:00:00 2001 From: etpinard Date: Tue, 1 Dec 2015 18:16:20 -0500 Subject: [PATCH 04/10] add jasmine plot interaction tests! --- test/jasmine/tests/plot_interact_test.js | 177 +++++++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100644 test/jasmine/tests/plot_interact_test.js diff --git a/test/jasmine/tests/plot_interact_test.js b/test/jasmine/tests/plot_interact_test.js new file mode 100644 index 00000000000..e37a599305c --- /dev/null +++ b/test/jasmine/tests/plot_interact_test.js @@ -0,0 +1,177 @@ +var d3 = require('d3'); + +var Plotly = require('@src/index'); +var Fx = require('@src/plots/cartesian/graph_interact'); + + +describe('Test plot structure', function () { + 'use strict'; + + function createGraphDiv() { + var gd = document.createElement('div'); + gd.id = 'graph'; + document.body.appendChild(gd); + return gd; + } + + function destroyGraphDiv() { + var gd = document.getElementById('graph'); + document.body.removeChild(gd); + } + + afterEach(destroyGraphDiv); + + describe('cartesian plots', function() { + describe('scatter traces', function() { + var mock = require('@mocks/14.json'); + + beforeEach(function(done) { + Plotly.plot(createGraphDiv(), mock.data, mock.layout).then(done); + }); + + it('has one *subplot xy* node', function() { + var nodes = d3.selectAll('g.subplot.xy'); + expect(nodes[0].length).toEqual(1); + }); + + it('has one *scatterlayer* node', function() { + var nodes = d3.selectAll('g.scatterlayer'); + expect(nodes[0].length).toEqual(1); + }); + + it('has as many *trace scatter* nodes as there are traces', function() { + var nodes = d3.selectAll('g.trace.scatter'); + expect(nodes[0].length).toEqual(mock.data.length); + }); + + it('has as many *point* nodes as there are traces', function() { + var nodes = d3.selectAll('path.point'); + + var Npts = 0; + mock.data.forEach(function(trace) { + Npts += trace.x.length; + }); + + expect(nodes[0].length).toEqual(Npts); + }); + + it('responds to hover', function() { + var gd = document.getElementById('graph'); + + var evt = { + clientX: gd.layout.width/ 2, + clientY: gd.layout.height / 2 + }; + + Fx.hover('graph', evt, 'xy'); + + var hoverTrace = gd._hoverdata[0]; + + expect(hoverTrace.curveNumber).toEqual(0); + expect(hoverTrace.pointNumber).toEqual(17); + expect(hoverTrace.x).toEqual(0.388); + expect(hoverTrace.y).toEqual(1); + + expect(d3.selectAll('g.axistext')[0].length).toEqual(1); + expect(d3.selectAll('g.hovertext')[0].length).toEqual(1); + }); + }); + + describe('pie traces', function() { + var mock = require('@mocks/pie_simple.json'); + + beforeEach(function(done) { + Plotly.plot(createGraphDiv(), mock.data, mock.layout).then(done); + }); + + it('has as many *slice* nodes as there are pie items', function() { + var nodes = d3.selectAll('g.slice'); + + var Npts = 0; + mock.data.forEach(function(trace) { + Npts += trace.values.length; + }); + + expect(nodes[0].length).toEqual(Npts); + }); + }); + + }); + + describe('gl3d plots', function() { + var mock = require('@mocks/gl3d_marker-arrays.json'); + + beforeEach(function(done) { + Plotly.plot(createGraphDiv(), mock.data, mock.layout).then(done); + }); + + it('has one *canvas* node', function() { + var nodes = d3.selectAll('canvas'); + expect(nodes[0].length).toEqual(1); + }); + }); + + describe('gl2d plots', function() { + var mock = require('@mocks/gl2d_10.json'); + + beforeEach(function(done) { + Plotly.plot(createGraphDiv(), mock.data, mock.layout).then(done); + }); + + it('has one *canvas* node', function() { + var nodes = d3.selectAll('canvas'); + expect(nodes[0].length).toEqual(1); + }); + }); + + describe('geo plots', function() { + var mock = require('@mocks/geo_first.json'); + + beforeEach(function(done) { + Plotly.plot(createGraphDiv(), mock.data, mock.layout).then(done); + }); + + it('has as many *choroplethlocation* nodes as there are choropleth locations', function() { + var nodes = d3.selectAll('path.choroplethlocation'); + + var Npts = 0; + mock.data.forEach(function(trace) { + var items = trace.locations; + if(items) Npts += items.length; + }); + + expect(nodes[0].length).toEqual(Npts); + }); + + it('has as many *point* nodes as there are marker points', function() { + var nodes = d3.selectAll('path.point'); + + var Npts = 0; + mock.data.forEach(function(trace) { + var items = trace.lat; + if(items) Npts += items.length; + }); + + expect(nodes[0].length).toEqual(Npts); + }); + }); + + describe('polar plots', function() { + var mock = require('@mocks/polar_scatter.json'); + + beforeEach(function(done) { + Plotly.plot(createGraphDiv(), mock.data, mock.layout).then(done); + }); + + it('has as many *mark dot* nodes as there are points', function() { + var nodes = d3.selectAll('path.mark.dot'); + + var Npts = 0; + mock.data.forEach(function(trace) { + Npts += trace.r.length; + }); + + expect(nodes[0].length).toEqual(Npts); + }); + }); +}); From 8f28b809b13e207275cb641ad18688b24b311cce Mon Sep 17 00:00:00 2001 From: etpinard Date: Wed, 2 Dec 2015 11:33:44 -0500 Subject: [PATCH 05/10] try Chrome for circleci karma/jasmine tests --- test/jasmine/karma.ciconf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jasmine/karma.ciconf.js b/test/jasmine/karma.ciconf.js index 5772b47ae00..69aec9db683 100644 --- a/test/jasmine/karma.ciconf.js +++ b/test/jasmine/karma.ciconf.js @@ -14,7 +14,7 @@ function func(config) { func.defaultConfig.autoWatch = false; - func.defaultConfig.browsers = ['Firefox']; + func.defaultConfig.browsers = ['Chrome']; config.set(func.defaultConfig); } From 6add1a4367b01910756ad210852dbdc48488e656 Mon Sep 17 00:00:00 2001 From: etpinard Date: Wed, 2 Dec 2015 11:43:04 -0500 Subject: [PATCH 06/10] Revert "try Chrome for circleci karma/jasmine tests" This reverts commit 8f28b809b13e207275cb641ad18688b24b311cce. --- test/jasmine/karma.ciconf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jasmine/karma.ciconf.js b/test/jasmine/karma.ciconf.js index 69aec9db683..5772b47ae00 100644 --- a/test/jasmine/karma.ciconf.js +++ b/test/jasmine/karma.ciconf.js @@ -14,7 +14,7 @@ function func(config) { func.defaultConfig.autoWatch = false; - func.defaultConfig.browsers = ['Chrome']; + func.defaultConfig.browsers = ['Firefox']; config.set(func.defaultConfig); } From 1970855d30f85b19bc049ed197e7f69c86db6c12 Mon Sep 17 00:00:00 2001 From: etpinard Date: Wed, 2 Dec 2015 11:53:40 -0500 Subject: [PATCH 07/10] mv gl plot interact tests to gl_plot_interact_test file: - exclude that test file on circleci runs - that way, gl plot interactions can be tested locally --- test/jasmine/karma.ciconf.js | 5 ++ test/jasmine/tests/gl_plot_interact_test.js | 55 +++++++++++++++++++++ test/jasmine/tests/plot_interact_test.js | 26 ---------- 3 files changed, 60 insertions(+), 26 deletions(-) create mode 100644 test/jasmine/tests/gl_plot_interact_test.js diff --git a/test/jasmine/karma.ciconf.js b/test/jasmine/karma.ciconf.js index 5772b47ae00..e7e2bbdfee2 100644 --- a/test/jasmine/karma.ciconf.js +++ b/test/jasmine/karma.ciconf.js @@ -7,6 +7,10 @@ function func(config) { func.defaultConfig.logLevel = config.LOG_INFO; // Continuous Integration mode + + // exclude the WebGL interaction test on circle runs + func.defaultConfig.exclude = ['tests/gl_plot_interact_test.js']; + // if true, Karma captures browsers, runs the tests and exits func.defaultConfig.singleRun = true; @@ -16,6 +20,7 @@ function func(config) { func.defaultConfig.browsers = ['Firefox']; + config.set(func.defaultConfig); } diff --git a/test/jasmine/tests/gl_plot_interact_test.js b/test/jasmine/tests/gl_plot_interact_test.js new file mode 100644 index 00000000000..76b33bf78be --- /dev/null +++ b/test/jasmine/tests/gl_plot_interact_test.js @@ -0,0 +1,55 @@ +var d3 = require('d3'); + +var Plotly = require('@src/index'); + +/* + * The following test cases fail on the CircleCI + * most likely due to a WebGL/driver issue + * + */ + + +describe('Test plot structure', function () { + 'use strict'; + + function createGraphDiv() { + var gd = document.createElement('div'); + gd.id = 'graph'; + document.body.appendChild(gd); + return gd; + } + + function destroyGraphDiv() { + var gd = document.getElementById('graph'); + document.body.removeChild(gd); + } + + afterEach(destroyGraphDiv); + + describe('gl3d plots', function() { + var mock = require('@mocks/gl3d_marker-arrays.json'); + + beforeEach(function(done) { + Plotly.plot(createGraphDiv(), mock.data, mock.layout).then(done); + }); + + it('has one *canvas* node', function() { + var nodes = d3.selectAll('canvas'); + expect(nodes[0].length).toEqual(1); + }); + }); + + describe('gl2d plots', function() { + var mock = require('@mocks/gl2d_10.json'); + + beforeEach(function(done) { + Plotly.plot(createGraphDiv(), mock.data, mock.layout).then(done); + }); + + it('has one *canvas* node', function() { + var nodes = d3.selectAll('canvas'); + expect(nodes[0].length).toEqual(1); + }); + }); + +}); diff --git a/test/jasmine/tests/plot_interact_test.js b/test/jasmine/tests/plot_interact_test.js index e37a599305c..99d0aff915a 100644 --- a/test/jasmine/tests/plot_interact_test.js +++ b/test/jasmine/tests/plot_interact_test.js @@ -98,32 +98,6 @@ describe('Test plot structure', function () { }); - describe('gl3d plots', function() { - var mock = require('@mocks/gl3d_marker-arrays.json'); - - beforeEach(function(done) { - Plotly.plot(createGraphDiv(), mock.data, mock.layout).then(done); - }); - - it('has one *canvas* node', function() { - var nodes = d3.selectAll('canvas'); - expect(nodes[0].length).toEqual(1); - }); - }); - - describe('gl2d plots', function() { - var mock = require('@mocks/gl2d_10.json'); - - beforeEach(function(done) { - Plotly.plot(createGraphDiv(), mock.data, mock.layout).then(done); - }); - - it('has one *canvas* node', function() { - var nodes = d3.selectAll('canvas'); - expect(nodes[0].length).toEqual(1); - }); - }); - describe('geo plots', function() { var mock = require('@mocks/geo_first.json'); From 24caa5ebe5bc191760493eca19b68c79ebee87be Mon Sep 17 00:00:00 2001 From: etpinard Date: Wed, 2 Dec 2015 13:43:23 -0500 Subject: [PATCH 08/10] improve comments --- test/image/compare_pixels_test.js | 15 ++++++++++++--- test/jasmine/karma.ciconf.js | 7 ++++++- test/jasmine/tests/gl_plot_interact_test.js | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/test/image/compare_pixels_test.js b/test/image/compare_pixels_test.js index 9de32789902..7538f739d44 100644 --- a/test/image/compare_pixels_test.js +++ b/test/image/compare_pixels_test.js @@ -28,9 +28,18 @@ function runAll () { var files = fs.readdirSync(constants.pathToTestImageMocks); - // -1 for font-wishlist and - // -38 for the gl2d mocks - // -1 for gl3d_bunny-hull + /* + * Some test cases exhibit run-to-run randomness; + * skip over a few test cases for now + * + * More info: + * https://github.com/plotly/plotly.js/issues/62 + * + * 40 test case are removed: + * - font-wishlist (1 test case) + * - all gl2d (38) + * - gl2d_bunny-hull (1) + */ t.plan(files.length - 40); for (var i = 0; i < files.length; i ++) { diff --git a/test/jasmine/karma.ciconf.js b/test/jasmine/karma.ciconf.js index e7e2bbdfee2..8d0651e0968 100644 --- a/test/jasmine/karma.ciconf.js +++ b/test/jasmine/karma.ciconf.js @@ -8,7 +8,12 @@ function func(config) { // Continuous Integration mode - // exclude the WebGL interaction test on circle runs + /* + * WebGL interaction test cases fail on the CircleCI + * most likely due to a WebGL/driver issue; + * exclude them from the CircleCI test bundle. + * + */ func.defaultConfig.exclude = ['tests/gl_plot_interact_test.js']; // if true, Karma captures browsers, runs the tests and exits diff --git a/test/jasmine/tests/gl_plot_interact_test.js b/test/jasmine/tests/gl_plot_interact_test.js index 76b33bf78be..fbace0a45f2 100644 --- a/test/jasmine/tests/gl_plot_interact_test.js +++ b/test/jasmine/tests/gl_plot_interact_test.js @@ -3,7 +3,7 @@ var d3 = require('d3'); var Plotly = require('@src/index'); /* - * The following test cases fail on the CircleCI + * WebGL interaction test cases fail on the CircleCI * most likely due to a WebGL/driver issue * */ From 35c59c9983c371bb1b30b444a4cd3d2ed678ac88 Mon Sep 17 00:00:00 2001 From: etpinard Date: Wed, 2 Dec 2015 13:45:48 -0500 Subject: [PATCH 09/10] fix typo in comments --- test/image/compare_pixels_test.js | 4 ++-- test/jasmine/karma.ciconf.js | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/test/image/compare_pixels_test.js b/test/image/compare_pixels_test.js index 7538f739d44..0caf0136bff 100644 --- a/test/image/compare_pixels_test.js +++ b/test/image/compare_pixels_test.js @@ -30,12 +30,12 @@ function runAll () { /* * Some test cases exhibit run-to-run randomness; - * skip over a few test cases for now + * skip over these few test cases for now. * * More info: * https://github.com/plotly/plotly.js/issues/62 * - * 40 test case are removed: + * 40 test cases are removed: * - font-wishlist (1 test case) * - all gl2d (38) * - gl2d_bunny-hull (1) diff --git a/test/jasmine/karma.ciconf.js b/test/jasmine/karma.ciconf.js index 8d0651e0968..3e044c77df8 100644 --- a/test/jasmine/karma.ciconf.js +++ b/test/jasmine/karma.ciconf.js @@ -25,7 +25,6 @@ function func(config) { func.defaultConfig.browsers = ['Firefox']; - config.set(func.defaultConfig); } From 7deeec7fa550d01480c87f757c0ef2d57ac6dc4d Mon Sep 17 00:00:00 2001 From: etpinard Date: Wed, 2 Dec 2015 13:51:05 -0500 Subject: [PATCH 10/10] put create and destroy graph div routine in jasmine tests assets/ --- test/jasmine/assets/create_graph_div.js | 8 ++++++++ test/jasmine/assets/destroy_graph_div.js | 6 ++++++ test/jasmine/tests/gl_plot_interact_test.js | 15 +++------------ test/jasmine/tests/plot_interact_test.js | 15 +++------------ 4 files changed, 20 insertions(+), 24 deletions(-) create mode 100644 test/jasmine/assets/create_graph_div.js create mode 100644 test/jasmine/assets/destroy_graph_div.js diff --git a/test/jasmine/assets/create_graph_div.js b/test/jasmine/assets/create_graph_div.js new file mode 100644 index 00000000000..0788b7f5dbc --- /dev/null +++ b/test/jasmine/assets/create_graph_div.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = function createGraphDiv() { + var gd = document.createElement('div'); + gd.id = 'graph'; + document.body.appendChild(gd); + return gd; +}; diff --git a/test/jasmine/assets/destroy_graph_div.js b/test/jasmine/assets/destroy_graph_div.js new file mode 100644 index 00000000000..84f3d72eaa7 --- /dev/null +++ b/test/jasmine/assets/destroy_graph_div.js @@ -0,0 +1,6 @@ +'use strict'; + +module.exports = function destroyGraphDiv() { + var gd = document.getElementById('graph'); + document.body.removeChild(gd); +}; diff --git a/test/jasmine/tests/gl_plot_interact_test.js b/test/jasmine/tests/gl_plot_interact_test.js index fbace0a45f2..abc7807a83e 100644 --- a/test/jasmine/tests/gl_plot_interact_test.js +++ b/test/jasmine/tests/gl_plot_interact_test.js @@ -2,6 +2,9 @@ var d3 = require('d3'); var Plotly = require('@src/index'); +var createGraphDiv = require('../assets/create_graph_div'); +var destroyGraphDiv = require('../assets/destroy_graph_div'); + /* * WebGL interaction test cases fail on the CircleCI * most likely due to a WebGL/driver issue @@ -12,18 +15,6 @@ var Plotly = require('@src/index'); describe('Test plot structure', function () { 'use strict'; - function createGraphDiv() { - var gd = document.createElement('div'); - gd.id = 'graph'; - document.body.appendChild(gd); - return gd; - } - - function destroyGraphDiv() { - var gd = document.getElementById('graph'); - document.body.removeChild(gd); - } - afterEach(destroyGraphDiv); describe('gl3d plots', function() { diff --git a/test/jasmine/tests/plot_interact_test.js b/test/jasmine/tests/plot_interact_test.js index 99d0aff915a..bddb8492853 100644 --- a/test/jasmine/tests/plot_interact_test.js +++ b/test/jasmine/tests/plot_interact_test.js @@ -3,22 +3,13 @@ var d3 = require('d3'); var Plotly = require('@src/index'); var Fx = require('@src/plots/cartesian/graph_interact'); +var createGraphDiv = require('../assets/create_graph_div'); +var destroyGraphDiv = require('../assets/destroy_graph_div'); + describe('Test plot structure', function () { 'use strict'; - function createGraphDiv() { - var gd = document.createElement('div'); - gd.id = 'graph'; - document.body.appendChild(gd); - return gd; - } - - function destroyGraphDiv() { - var gd = document.getElementById('graph'); - document.body.removeChild(gd); - } - afterEach(destroyGraphDiv); describe('cartesian plots', function() {