Skip to content

Commit

Permalink
feat(bottom-sheet): some improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
v-gevak committed Jul 26, 2023
1 parent b205104 commit dad8043
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 52 deletions.
17 changes: 12 additions & 5 deletions packages/bottom-sheet/src/component.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -386,49 +386,55 @@ describe('Bottom sheet', () => {
expect(component).not.toBeInTheDocument();
});

it('should call onMagnetize prop after opening', async () => {
it('should call onMagnetize and onMagnetizeEnd prop after opening', async () => {
const onMagnetize = jest.fn();
const onMagnetizeEnd = jest.fn();

render(
<BottomSheetWrapper
onMagnetize={onMagnetize}
onMagnetizeEnd={onMagnetizeEnd}
transitionProps={{
timeout: 0,
}}
/>,
);

await waitFor(() => expect(onMagnetize).toBeCalledWith(1));
await waitFor(() => expect(onMagnetizeEnd).toBeCalledTimes(1));
});

it('should call onMagnetize prop with initialAreaIdx after opening', async () => {
it('should call onMagnetize and onMagnetizeEnd prop with initialAreaIdx after opening', async () => {
const onMagnetize = jest.fn();
const onMagnetizeEnd = jest.fn();

render(
<BottomSheetWrapper
magneticAreas={[0, 200, 500]}
initialActiveAreaIndex={1}
onMagnetize={onMagnetize}
onMagnetizeEnd={onMagnetizeEnd}
transitionProps={{
timeout: 0,
}}
/>,
);

await waitFor(() => expect(onMagnetize).toBeCalledWith(1));
await waitFor(() => expect(onMagnetizeEnd).toBeCalledTimes(1));
});

it('should call onMagnetize prop after closing', async () => {
it('should call onMagnetize and onMagnetizeEnd prop after closing', async () => {
const onMagnetize = jest.fn();
const onEntered = jest.fn();
const onMagnetizeEnd = jest.fn();

const { getByTestId } = render(
<BottomSheetWrapper
dataTestId={dataTestId}
onMagnetize={onMagnetize}
onMagnetizeEnd={onMagnetizeEnd}
transitionProps={{
timeout: 0,
onEntered,
}}
/>,
);
Expand All @@ -437,6 +443,7 @@ describe('Bottom sheet', () => {
fireEvent.mouseUp(getByTestId(dataTestId));

await waitFor(() => expect(onMagnetize).toBeCalledWith(0));
await waitFor(() => expect(onMagnetizeEnd).toBeCalledTimes(1));
});
});
});
Loading

0 comments on commit dad8043

Please sign in to comment.