drawer.test.tsx 960 B

12345678910111213141516171819202122232425262728293031
  1. /* eslint-disable no-undef */
  2. import React from 'react';
  3. import { cleanup } from '@testing-library/react';
  4. import testWrapper from '../helpers/testWrapper';
  5. import Drawer from '../components/Drawer';
  6. describe('Drawer component', () => {
  7. afterEach(cleanup);
  8. test('drawer content', () => {
  9. const { getByText } = testWrapper(<Drawer>content</Drawer>);
  10. expect(getByText('content').textContent).toBe('content');
  11. });
  12. test('close drawer', () => {
  13. const { getByTestId } = testWrapper(<Drawer>content</Drawer>);
  14. const ele = getByTestId('drawer');
  15. const style = window.getComputedStyle(ele as HTMLElement);
  16. expect(style.transform).toBe('translate(0,267px)');
  17. });
  18. test('open drawer', () => {
  19. const { getByTestId } = testWrapper(<Drawer open>content</Drawer>);
  20. const ele = getByTestId('drawer');
  21. const style = window.getComputedStyle(ele as HTMLElement);
  22. expect(style.transform).toBe('translate(0,0)');
  23. });
  24. });