@@ -10,7 +10,7 @@ describe('<VueUiDonut />', () => {
1010 }
1111 } )
1212 cy . fixture ( 'donut.json' ) . as ( 'fixture' ) ;
13- cy . viewport ( 1000 , 1100 ) ;
13+
1414 } ) ;
1515
1616 function updateConfigInFixture ( modifiedConfig ) {
@@ -20,7 +20,44 @@ describe('<VueUiDonut />', () => {
2020 } ) ;
2121 }
2222
23+ it ( 'highlights a series on hover and displays tooltip' , ( ) => {
24+ cy . viewport ( 1000 , 850 ) ;
25+ cy . get ( '@fixture' ) . then ( ( fixture ) => {
26+ cy . mount ( VueUiDonut , {
27+ props : {
28+ dataset : fixture . dataset ,
29+ config : fixture . config
30+ }
31+ } ) ;
32+
33+ const sortedDataset = fixture . dataset . toSorted ( ( a , b ) => b . values . reduce ( ( x , y ) => x + y , 0 ) - a . values . reduce ( ( x , y ) => x + y , 0 ) )
34+
35+ cy . get ( '[data-cy="donut-trap-0"]' ) . trigger ( 'mouseenter' , { force : true } )
36+ cy . get ( '[data-cy="tooltip"]' ) . should ( 'be.visible' ) . contains ( sortedDataset [ 0 ] . name )
37+ } )
38+ } )
39+
40+ it ( 'segregates series on legend click' , ( ) => {
41+ cy . viewport ( 1000 , 850 ) ;
42+ cy . get ( '@fixture' ) . then ( ( fixture ) => {
43+ cy . mount ( VueUiDonut , {
44+ props : {
45+ dataset : fixture . dataset ,
46+ config : fixture . config
47+ }
48+ } ) ;
49+
50+ const sortedDataset = fixture . dataset . toSorted ( ( a , b ) => b . values . reduce ( ( x , y ) => x + y , 0 ) - a . values . reduce ( ( x , y ) => x + y , 0 ) )
51+
52+ cy . get ( '[data-cy="legend-item-0"]' ) . click ( )
53+ cy . get ( '[data-cy-donut-trap]' ) . should ( 'have.length' , sortedDataset . length - 1 )
54+ cy . get ( '[data-cy="legend-item-0"]' ) . click ( )
55+ cy . get ( '[data-cy-donut-trap]' ) . should ( 'have.length' , sortedDataset . length )
56+ } )
57+ } )
58+
2359 it ( 'renders with different config attributes' , function ( ) {
60+ cy . viewport ( 1000 , 1100 ) ;
2461 cy . get ( '@fixture' ) . then ( ( fixture ) => {
2562 cy . mount ( VueUiDonut , {
2663 props : {
@@ -139,13 +176,10 @@ describe('<VueUiDonut />', () => {
139176 } ) ;
140177
141178 cy . get ( `[data-cy="user-options-pdf"]` ) . click ( { force : true } ) ;
142- cy . wait ( 5000 ) ;
143179 cy . readFile ( `cypress\\Downloads\\${ fixture . config . style . chart . title . text } .pdf` ) ;
144180 cy . get ( `[data-cy="user-options-xls"]` ) . click ( { force : true } ) ;
145- cy . wait ( 3000 ) ;
146181 cy . readFile ( `cypress\\Downloads\\${ fixture . config . style . chart . title . text } .csv` ) ;
147182 cy . get ( `[data-cy="user-options-img"]` ) . click ( { force : true } ) ;
148- cy . wait ( 3000 ) ;
149183 cy . readFile ( `cypress\\Downloads\\${ fixture . config . style . chart . title . text } .png` ) ;
150184 cy . clearDownloads ( ) ;
151185 } ) ;
0 commit comments