Skip to content

Commit

Permalink
Use AdoptivityProvider to setup desktop env
Browse files Browse the repository at this point in the history
  • Loading branch information
mendrew committed Mar 22, 2024
1 parent 323f93d commit 21089dd
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions packages/vkui/src/components/Snackbar/Snackbar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,10 @@ import * as React from 'react';
import { render, screen } from '@testing-library/react';
import { ViewWidth } from '../../lib/adaptivity';
import { baselineComponent } from '../../testing/utils';
import { AdaptivityProvider } from '../AdaptivityProvider/AdaptivityProvider';
import { Snackbar } from './Snackbar';
import styles from './Snackbar.module.css';

const getViewWidthStub = jest.fn().mockReturnValue(ViewWidth.MOBILE);
jest.mock('../../hooks/useAdaptivityWithJSMediaQueries', () => ({
useAdaptivityWithJSMediaQueries() {
return {
get viewWidth() {
return getViewWidthStub();
},
};
},
}));

describe('Snackbar', () => {
baselineComponent((props) => <Snackbar onClose={jest.fn()} {...props} />);

Expand All @@ -26,11 +16,12 @@ describe('Snackbar', () => {
});

it('renders in horizontal layout on desktop if layout prop is set', () => {
getViewWidthStub.mockReturnValue(ViewWidth.DESKTOP);
const { container, rerender } = render(
<Snackbar action="Close me" onClose={jest.fn()}>
Text message
</Snackbar>,
<AdaptivityProvider viewWidth={ViewWidth.DESKTOP}>
<Snackbar action="Close me" onClose={jest.fn()}>
Text message
</Snackbar>
</AdaptivityProvider>,
);

// renders in vertical layout on desktop by default
Expand Down

0 comments on commit 21089dd

Please sign in to comment.