Skip to content

Commit

Permalink
fix: failing test cases for drawer component (#15876)
Browse files Browse the repository at this point in the history
  • Loading branch information
vinu-deriv committed Jul 1, 2024
1 parent 1151760 commit b12af3e
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import { StoreProvider, mockStore } from '@deriv/stores';
import Drawer from '../drawer';


describe('Drawer', () => {
const mock_store = mockStore({});
const renderComponent = (props : React.ComponentProps<typeof Drawer>) => {
const wrapper = ({ children }: { children: JSX.Element }) => (
<StoreProvider store={mock_store}>{children}</StoreProvider>
);

render(<Drawer {...props} />, {
wrapper,
});
};

it('should Drawer be in the document', () => {
render(<Drawer is_open={false} />);
renderComponent({is_open:false});
expect(screen.getByTestId('drawer')).toBeInTheDocument();
});

it('should Drawer be open if is_open="true" ', () => {
render(<Drawer is_open={true} />);
renderComponent({is_open:true});
expect(screen.getByTestId('drawer')).toHaveClass('dc-drawer--open');
});

it('should Drawer be open if is_open="false" ', () => {
render(<Drawer is_open={false} />);
renderComponent({is_open:false});
expect(screen.getByTestId('drawer')).not.toHaveClass('dc-drawer--open');
});
});

0 comments on commit b12af3e

Please sign in to comment.