Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Brown committed Dec 17, 2024
1 parent e2d712a commit b730b5f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/bpk-scrim-utils/src/withScrim-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ describe('BpkScrim', () => {
it('should mount correctly when is not iPhone', () => {
const mockSetAttribute = jest.fn();
const mockRemoveAttribute = jest.fn();
const mockCustomPaddingElement = document.createElement('div');

render(
<Component
onClose={jest.fn()}
Expand All @@ -158,11 +160,12 @@ describe('BpkScrim', () => {
setAttribute: mockSetAttribute,
removeAttribute: mockRemoveAttribute,
}))}
getCustomPaddingElement={() => mockCustomPaddingElement}
isIphone={false}
/>,
);
jest.runAllTimers();
expect(lockScroll).toHaveBeenCalled();
expect(lockScroll).toHaveBeenCalledWith(mockCustomPaddingElement);
expect(focusStore.storeFocus).toHaveBeenCalled();
expect(storeScroll).not.toHaveBeenCalled();
expect(fixBody).not.toHaveBeenCalled();
Expand All @@ -182,6 +185,7 @@ describe('BpkScrim', () => {
it('should unmount correctly when is iPhone', async () => {
const mockSetAttribute = jest.fn();
const mockRemoveAttribute = jest.fn();

const { unmount } = render(
<Component
onClose={jest.fn()}
Expand All @@ -206,6 +210,8 @@ describe('BpkScrim', () => {

it('should unmount correctly when is not iPhone', () => {
const mockRemoveAttribute = jest.fn();
const mockCustomPaddingElement = document.createElement('div');

const { unmount } = render(
<Component
onClose={jest.fn()}
Expand All @@ -214,12 +220,13 @@ describe('BpkScrim', () => {
setAttribute: jest.fn(),
removeAttribute: mockRemoveAttribute,
}))}
getCustomPaddingElement={() => mockCustomPaddingElement}
isIphone={false}
/>,
);
unmount();

expect(unlockScroll).toHaveBeenCalled();
expect(unlockScroll).toHaveBeenCalledWith(mockCustomPaddingElement);
expect(restoreScroll).not.toHaveBeenCalled();
expect(unfixBody).not.toHaveBeenCalled();
expect(focusStore.storeFocus).toHaveBeenCalled();
Expand Down

0 comments on commit b730b5f

Please sign in to comment.