Skip to content

Commit e47a3f7

Browse files
committed
✅ Simplify test by only have a single option
1 parent 08e32a4 commit e47a3f7

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

src/molecules/Tabs/Tabs.test.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,12 @@ test('Throws error if amountPerScrollPage is set but scrollable is false', () =>
192192

193193
test('Hovering over a tab calls the onHover callback', async () => {
194194
const props = fakeProps();
195-
render(<Tabs {...props} selected={0} />);
195+
const options = [{ value: 123, label: 'Option 1' }];
196+
render(<Tabs {...props} options={options} selected={0} />);
196197
const user = userEvent.setup();
197198

198-
for (const option of props.options) {
199-
expect(screen.getByRole('tab', { name: option.label }));
200-
}
201-
202-
const randomOption = faker.helpers.arrayElement(props.options);
203-
204-
await user.hover(screen.getByRole('tab', { name: randomOption.label }));
199+
await user.hover(screen.getByRole('tab', { name: options[0].label }));
200+
console.log('randomOption value', options[0].value);
205201

206-
expect(props.onHover).toHaveBeenCalledExactlyOnceWith(randomOption.value);
202+
expect(props.onHover).toHaveBeenCalledExactlyOnceWith(options[0].value);
207203
});

0 commit comments

Comments
 (0)