Skip to content

Commit ee4f087

Browse files
committed
chore: update DBTab test
use var instead of file to hold click event results for test duration
1 parent 73851f7 commit ee4f087

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

packages/components/src/components/tabs/tabs.spec.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
import AxeBuilder from '@axe-core/playwright';
22
import { expect, test } from '@playwright/experimental-ct-react';
33

4-
import { existsSync, rmSync, writeFileSync } from 'node:fs';
54
import { DBTabs } from './index';
65
// @ts-ignore - vue can only find it with .ts as file ending
76
import { DEFAULT_VIEWPORT } from '../../shared/constants.ts';
87
import { DBTabItem } from '../tab-item';
98
import { DBTabList } from '../tab-list';
109
import { DBTabPanel } from '../tab-panel';
1110

12-
const filePath = './test-results/onIndexChange.txt';
11+
let tabIndex: number;
1312

1413
const 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

4541
const 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

Comments
 (0)