import { mount } from '@vue/test-utils' ; import Chart from 'chart.js/auto' ; import CChart from './../index' ; class ResizeObserver { observe ( ) { } unobserve ( ) { } disconnect ( ) { } } window . ResizeObserver = ResizeObserver ; describe ( '<CChart />' , ( ) => { const data = { labels : [ 'red' , 'blue' ] , datasets : [ { label : 'colors' , data : [ 1 , 2 ] } ] , } ; const options = { responsive : false , } ; let chart , update , destroy ; const ref = ( el ) : void => { chart = el ; if ( chart ) { update = jest . spyOn ( chart , 'update' ) ; destroy = jest . spyOn ( chart , 'destroy' ) ; } } ; beforeEach ( ( ) => { chart = null ; } ) ; afterEach ( ( ) => { if ( chart ) chart . destroy ( ) ; if ( update ) update . mockClear ( ) ; if ( destroy ) destroy . mockClear ( ) ; } ) ; it ( 'should not pollute props' , ( ) => { mount ( CChart , { propsData : { data : data , options : options , wrapper : false , } , attrs : { ref : ref , } } ) ; expect ( data ) . toStrictEqual ( { labels : [ 'red' , 'blue' ] , datasets : [ { label : 'colors' , data : [ 1 , 2 ] } ] , } ) ; } ) ; } ) ;