routeSource.spec.jsx 1.3 KB

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