@@ -9,7 +9,10 @@ Plotly.register(
9
9
require ( '@lib/contourgl' )
10
10
) ;
11
11
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' ) ;
13
16
14
17
var plotData = {
15
18
'data' : [
@@ -158,48 +161,51 @@ var plotDataElliptical = function(maxJitter) {
158
161
} ;
159
162
160
163
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 ) ;
163
168
}
164
169
165
170
describe ( 'contourgl plots' , function ( ) {
166
171
172
+ var gd ;
173
+
174
+ beforeEach ( function ( ) {
175
+ gd = createGraphDiv ( ) ;
176
+ } ) ;
177
+
178
+ afterEach ( function ( ) {
179
+ Plotly . purge ( gd ) ;
180
+ destroyGraphDiv ( ) ;
181
+ } ) ;
182
+
167
183
// this first dataset is a special case, very forgiving to the contour renderer, as it's convex,
168
184
// contains no inflexion points etc.
169
185
it ( 'render without raising an error' , function ( done ) {
170
- withSetupTeardown ( done , function ( gd ) {
171
- return makePlot ( gd , plotData ) ;
172
- } ) ;
186
+ makePlot ( gd , plotData , done ) ;
173
187
} ) ;
174
188
175
189
it ( 'render without raising an error' , function ( done ) {
176
190
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 ) ;
180
192
} ) ;
181
193
182
194
it ( 'render without raising an error (coloring: "lines")' , function ( done ) {
183
195
var mock = Lib . extendDeep ( { } , plotDataElliptical ( 0 ) ) ;
184
196
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 ) ;
188
198
} ) ;
189
199
190
200
it ( 'render smooth, regular ellipses without raising an error (coloring: "fill")' , function ( done ) {
191
201
var mock = plotDataElliptical ( 0 ) ;
192
- withSetupTeardown ( done , function ( gd ) {
193
- return makePlot ( gd , mock ) ;
194
- } ) ;
202
+ makePlot ( gd , mock , done ) ;
195
203
} ) ;
196
204
197
205
it ( 'render ellipses with added noise without raising an error (coloring: "fill")' , function ( done ) {
198
206
var mock = plotDataElliptical ( 0.5 ) ;
199
207
mock . data [ 0 ] . contours . coloring = 'fill' ; // 'fill' is the default
200
208
mock . data [ 0 ] . line = { smoothing : 0 } ;
201
- withSetupTeardown ( done , function ( gd ) {
202
- return makePlot ( gd , mock ) ;
203
- } ) ;
209
+ makePlot ( gd , mock , done ) ;
204
210
} ) ;
205
211
} ) ;
0 commit comments