import { expect } from 'chai' ; import { DummyManager } from './dummy-manager' ; import bqplot = require ( '..' ) ; import { create_figure_scatter } from './widget-utils' ; describe ( 'figure >' , ( ) => { beforeEach ( async function ( ) { this . manager = new DummyManager ( { bqplot : bqplot } ) ; } ) ; it ( 'marks removed before created' , async function ( ) { const x = { dtype : 'float32' , value : new DataView ( new Float32Array ( [ 0.5 , 0.5 ] ) . buffer ) , } ; const y = { dtype : 'float32' , value : new DataView ( new Float32Array ( [ 2.0 , 2.5 ] ) . buffer ) , } ; const { scatter , figure } = await create_figure_scatter ( this . manager , x , y ) ; expect ( figure . fig_marks . node ( ) . children ) . lengthOf ( 2 ) ; figure . model . set ( 'marks' , [ ] ) ; await Promise . all ( figure . mark_views . views ) ; expect ( figure . fig_marks . node ( ) . children ) . lengthOf ( 1 ) ; figure . model . set ( 'marks' , [ scatter . model , scatter . model ] ) ; const previousViewsPromise = Promise . all ( figure . mark_views . views ) ; figure . model . set ( 'marks' , [ scatter . model ] ) ; await Promise . all ( figure . mark_views . views ) ; await previousViewsPromise ; expect ( figure . fig_marks . node ( ) . children ) . lengthOf ( 2 ) ; } ) ; } ) ;