@@ -4,6 +4,8 @@ import {fireEvent, render, screen} from '@testing-library/react'
44
55import { PlotEnv } from '../utils/PlotEnv'
66
7+ import { LineLayerConfig , SizedConfig } from '../types'
8+
79jest . mock ( './Geo' , ( ) => < > </ > ) // this component causes all sorts of loading problems
810
911import { newTable } from '../utils/newTable'
@@ -23,19 +25,23 @@ const layers = [
2325 type : 'line' ,
2426 x : '_time' ,
2527 y : '_value' ,
26- } ,
28+ fill : [ ] ,
29+ } as LineLayerConfig ,
2730]
2831
29- const config = {
32+ const config : SizedConfig = {
3033 table,
3134 layers,
3235 showAxes : false ,
33- width : '350px' ,
34- height : '350px' ,
36+ width : 350 ,
37+ height : 350 ,
3538}
3639
3740const resetSpy = jest . spyOn ( PlotEnv . prototype , 'resetDomains' )
3841
42+ const axesRef : React . RefObject < HTMLCanvasElement > = React . createRef ( )
43+ const layersRef : React . RefObject < HTMLCanvasElement > = React . createRef ( )
44+
3945describe ( 'the SizedPlot' , ( ) => {
4046 describe ( 'handling user interaction' , ( ) => {
4147 afterEach ( ( ) => {
@@ -44,7 +50,13 @@ describe('the SizedPlot', () => {
4450
4551 describe ( 'the default behavior' , ( ) => {
4652 it ( 'handles double clicks' , ( ) => {
47- render ( < SizedPlot config = { config } /> )
53+ render (
54+ < SizedPlot
55+ config = { config }
56+ axesCanvasRef = { axesRef }
57+ layerCanvasRef = { layersRef }
58+ />
59+ )
4860 fireEvent . doubleClick ( screen . getByTestId ( 'giraffe-inner-plot' ) )
4961
5062 expect ( resetSpy ) . toHaveBeenCalled ( )
@@ -59,7 +71,13 @@ describe('the SizedPlot', () => {
5971 interactionHandlers : { doubleClick : fakeDoubleClickInteractionHandler } ,
6072 }
6173
62- render ( < SizedPlot config = { localConfig } /> )
74+ render (
75+ < SizedPlot
76+ config = { localConfig }
77+ axesCanvasRef = { axesRef }
78+ layerCanvasRef = { layersRef }
79+ />
80+ )
6381 fireEvent . doubleClick ( screen . getByTestId ( 'giraffe-inner-plot' ) )
6482
6583 expect ( resetSpy ) . not . toHaveBeenCalled ( )
@@ -88,7 +106,13 @@ describe('the SizedPlot', () => {
88106 interactionHandlers : { hover : fakeHoverCallback } ,
89107 }
90108
91- render ( < SizedPlot config = { localConfig } /> )
109+ render (
110+ < SizedPlot
111+ config = { localConfig }
112+ axesCanvasRef = { axesRef }
113+ layerCanvasRef = { layersRef }
114+ />
115+ )
92116
93117 fireEvent . mouseOver ( screen . getByTestId ( 'giraffe-inner-plot' ) )
94118
0 commit comments