11import AxeBuilder from '@axe-core/playwright' ;
22import { expect , test } from '@playwright/experimental-ct-react' ;
33
4- import { existsSync , rmSync , writeFileSync } from 'node:fs' ;
54import { DBTabs } from './index' ;
65// @ts -ignore - vue can only find it with .ts as file ending
76import { DEFAULT_VIEWPORT } from '../../shared/constants.ts' ;
87import { DBTabItem } from '../tab-item' ;
98import { DBTabList } from '../tab-list' ;
109import { DBTabPanel } from '../tab-panel' ;
1110
12- const filePath = './test-results/onIndexChange.txt' ;
11+ let tabIndex : number ;
1312
1413const comp : any = (
15- < DBTabs
16- onIndexChange = { ( index : number ) =>
17- writeFileSync ( filePath , index . toString ( ) )
18- } >
14+ < DBTabs onIndexChange = { ( index : number ) => ( tabIndex = index ) } >
1915 < DBTabList >
2016 < DBTabItem data-testid = "test" > Test 1</ DBTabItem >
2117 < DBTabItem data-testid = "test2" > Test 2</ DBTabItem >
@@ -44,9 +40,7 @@ const testComponent = () => {
4440
4541const testActions = ( ) => {
4642 test ( 'should be clickable' , async ( { mount } ) => {
47- if ( existsSync ( filePath ) ) {
48- rmSync ( filePath ) ;
49- }
43+ expect ( tabIndex ) . toBe ( undefined ) ;
5044
5145 const component = await mount ( comp ) ;
5246 await component
@@ -59,7 +53,7 @@ const testActions = () => {
5953 . isChecked ( ) ;
6054 expect ( ! tabChecked ) . toBeTruthy ( ) ;
6155
62- expect ( existsSync ( filePath ) ) . toBeTruthy ( ) ;
56+ expect ( tabIndex ) . toBe ( 1 ) ;
6357 } ) ;
6458} ;
6559
0 commit comments