@@ -9,7 +9,10 @@ Plotly.register(
99 require ( '@lib/contourgl' )
1010) ;
1111
12- var withSetupTeardown = require ( '../assets/with_setup_teardown' ) ;
12+ // Test utilities
13+ var createGraphDiv = require ( '../assets/create_graph_div' ) ;
14+ var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
15+ var failTest = require ( '../assets/fail_test' ) ;
1316
1417var plotData = {
1518 'data' : [
@@ -158,48 +161,51 @@ var plotDataElliptical = function(maxJitter) {
158161} ;
159162
160163
161- function makePlot ( gd , mock ) {
162- return Plotly . plot ( gd , mock . data , mock . layout ) ;
164+ function makePlot ( gd , mock , done ) {
165+ return Plotly . plot ( gd , mock . data , mock . layout )
166+ . then ( null , failTest )
167+ . then ( done ) ;
163168}
164169
165170describe ( 'contourgl plots' , function ( ) {
166171
172+ var gd ;
173+
174+ beforeEach ( function ( ) {
175+ gd = createGraphDiv ( ) ;
176+ } ) ;
177+
178+ afterEach ( function ( ) {
179+ Plotly . purge ( gd ) ;
180+ destroyGraphDiv ( ) ;
181+ } ) ;
182+
167183 // this first dataset is a special case, very forgiving to the contour renderer, as it's convex,
168184 // contains no inflexion points etc.
169185 it ( 'render without raising an error' , function ( done ) {
170- withSetupTeardown ( done , function ( gd ) {
171- return makePlot ( gd , plotData ) ;
172- } ) ;
186+ makePlot ( gd , plotData , done ) ;
173187 } ) ;
174188
175189 it ( 'render without raising an error' , function ( done ) {
176190 var mock = require ( '@mocks/gl2d_simple_contour_fill.json' ) ;
177- withSetupTeardown ( done , function ( gd ) {
178- return makePlot ( gd , mock ) ;
179- } ) ;
191+ makePlot ( gd , mock , done ) ;
180192 } ) ;
181193
182194 it ( 'render without raising an error (coloring: "lines")' , function ( done ) {
183195 var mock = Lib . extendDeep ( { } , plotDataElliptical ( 0 ) ) ;
184196 mock . data [ 0 ] . contours . coloring = 'lines' ; // 'fill' is the default
185- withSetupTeardown ( done , function ( gd ) {
186- return makePlot ( gd , mock ) ;
187- } ) ;
197+ makePlot ( gd , mock , done ) ;
188198 } ) ;
189199
190200 it ( 'render smooth, regular ellipses without raising an error (coloring: "fill")' , function ( done ) {
191201 var mock = plotDataElliptical ( 0 ) ;
192- withSetupTeardown ( done , function ( gd ) {
193- return makePlot ( gd , mock ) ;
194- } ) ;
202+ makePlot ( gd , mock , done ) ;
195203 } ) ;
196204
197205 it ( 'render ellipses with added noise without raising an error (coloring: "fill")' , function ( done ) {
198206 var mock = plotDataElliptical ( 0.5 ) ;
199207 mock . data [ 0 ] . contours . coloring = 'fill' ; // 'fill' is the default
200208 mock . data [ 0 ] . line = { smoothing : 0 } ;
201- withSetupTeardown ( done , function ( gd ) {
202- return makePlot ( gd , mock ) ;
203- } ) ;
209+ makePlot ( gd , mock , done ) ;
204210 } ) ;
205211} ) ;
0 commit comments