routeSource.spec.jsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import React from 'react';
  2. import {mount} from 'enzyme';
  3. import {RouteSource} from 'app/components/search/sources/routeSource';
  4. describe('RouteSource', function() {
  5. let wrapper;
  6. it('can find a route', async function() {
  7. let mock = jest.fn().mockReturnValue(null);
  8. wrapper = mount(<RouteSource query="password">{mock}</RouteSource>);
  9. await tick();
  10. wrapper.update();
  11. let calls = mock.mock.calls;
  12. expect(calls[calls.length - 1][0].results[0].item).toEqual({
  13. description: 'Change your account password and/or two factor authentication',
  14. path: '/settings/account/security/',
  15. resultType: 'route',
  16. sourceType: 'route',
  17. title: 'Security',
  18. to: '/settings/account/security/',
  19. });
  20. });
  21. it('does not find any form field ', async function() {
  22. let mock = jest.fn().mockReturnValue(null);
  23. wrapper = mount(<RouteSource query="invalid">{mock}</RouteSource>);
  24. await tick();
  25. wrapper.update();
  26. expect(mock).toHaveBeenCalledWith(
  27. expect.objectContaining({
  28. results: [],
  29. })
  30. );
  31. });
  32. });