-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: failing test cases for drawer component (#15876)
- Loading branch information
1 parent
1151760
commit b12af3e
Showing
1 changed file
with
16 additions
and
3 deletions.
There are no files selected for viewing
19 changes: 16 additions & 3 deletions
19
packages/components/src/components/drawer/__tests__/drawer.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}); | ||
}); |