Skip to content

Commit

Permalink
tests: add more assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
kamleshchandnani committed Dec 28, 2023
1 parent 3291bb9 commit 84b1a66
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ TestCarouselOnChange.play = async ({ canvasElement }) => {
getByText(/Single Flow To Collect And Disburse Payments/)?.scrollIntoView({ behavior: 'smooth' });
await sleep(1000);
await expect(onChange).toBeCalledWith(3);
await expect(onChange).toBeCalledTimes(3);
};

export const TestIndicatorButton: StoryFn<typeof CarouselComponent> = (
Expand All @@ -53,6 +54,7 @@ TestIndicatorButton.play = async ({ canvasElement }) => {
await userEvent.click(indicatorButton);
await sleep(1000);
await expect(onChange).toBeCalledWith(6);
await expect(onChange).toBeCalledTimes(1);
};

export const TestStartOverAfterStartEnd: StoryFn<typeof CarouselComponent> = (
Expand All @@ -72,6 +74,7 @@ TestStartOverAfterStartEnd.play = async ({ canvasElement }) => {
await userEvent.click(nextButton);
await sleep(1000);
await expect(onChange).toBeCalledWith(0);
await expect(onChange).toBeCalledTimes(2);
};

export const TestAutoPlay: StoryFn<typeof CarouselComponent> = (props): React.ReactElement => {
Expand All @@ -84,6 +87,7 @@ TestAutoPlay.play = async ({ canvasElement }) => {
await sleep(8000);
await expect(onChange).toBeCalledWith(1);
await expect(getByRole('tab', { selected: true })).toHaveAccessibleName('Slide 3');
await expect(onChange).toBeCalledTimes(1);
};

export const TestAutofit: StoryFn<typeof CarouselComponent> = (props): React.ReactElement => {
Expand Down Expand Up @@ -113,6 +117,7 @@ TestAutofit.play = async ({ canvasElement }) => {
await sleep(1000);
const previousButton = queryByRole('button', { name: 'Previous Slide' });
await expect(previousButton).toBeNull();
await expect(onChange).toBeCalledTimes(2);
};

export const TestAutoPlayPause: StoryFn<typeof CarouselComponent> = (props): React.ReactElement => {
Expand All @@ -125,7 +130,7 @@ TestAutoPlayPause.play = async ({ canvasElement }) => {
const slide = getByText(/Acquire Customers From New Customer Segments/);
await userEvent.hover(slide);
await sleep(7000);
await expect(onChange).toBeCalledTimes(0);
await expect(onChange).not.toHaveBeenCalled();
};

export const TestVisibleItemsOnMobile: StoryFn<typeof CarouselComponent> = (
Expand Down

0 comments on commit 84b1a66

Please sign in to comment.