Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. import React from 'react';
  2. import { render, cleanup } from 'react-testing-library';
  3.  
  4. import { AppsNav } from '.';
  5.  
  6. describe('<AppsNav />', () => {
  7. afterEach(cleanup);
  8.  
  9. const history = {
  10. listen: jest.fn(),
  11. };
  12. const props = {
  13. classes: {},
  14. location: { pathname: '/' },
  15. navActions: {},
  16. history,
  17. open: false,
  18. };
  19.  
  20. it('should have a Service Center link', () => {
  21. const { queryAllByText } = render(<AppsNav {...props} />);
  22. expect(queryAllByText('Service Center')).toHaveLength(1);
  23. });
  24.  
  25. it('should renders as hidden for mobile by default', () => {
  26. window.matchMedia = jest.fn().mockImplementation(query => {
  27. return {
  28. matches: false,
  29. media: query,
  30. onchange: null,
  31. addListener: jest.fn(),
  32. removeListener: jest.fn(),
  33. };
  34. });
  35. const { getByTestId } = render(<AppsNav {...props} open={false} />);
  36. expect(getByTestId('custom-drawer'));
  37. });
  38.  
  39. it('renders as shown for mobile when not hidden', () => {
  40. window.matchMedia = jest.fn().mockImplementation(query => {
  41. return {
  42. matches: false,
  43. media: query,
  44. onchange: null,
  45. addListener: jest.fn(),
  46. removeListener: jest.fn(),
  47. };
  48. });
  49. const { getByTestId } = render(<AppsNav {...props} open />);
  50. expect(getByTestId('custom-drawer-open'));
  51. });
  52. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement