accountSettingsLayout.spec.jsx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import {BreadcrumbContextProvider} from 'sentry-test/providers/breadcrumbContextProvider';
  2. import {render} from 'sentry-test/reactTestingLibrary';
  3. import * as OrgActions from 'sentry/actionCreators/organizations';
  4. import AccountSettingsLayout from 'sentry/views/settings/account/accountSettingsLayout';
  5. describe('AccountSettingsLayout', function () {
  6. let spy;
  7. let api;
  8. const organization = {
  9. id: '44',
  10. name: 'Org Index',
  11. slug: 'org-index',
  12. };
  13. beforeEach(function () {
  14. spy = jest.spyOn(OrgActions, 'fetchOrganizationDetails');
  15. api = MockApiClient.addMockResponse({
  16. url: `/organizations/${organization.slug}/`,
  17. });
  18. });
  19. it('fetches org details for SidebarDropdown', function () {
  20. const {rerender} = render(
  21. <BreadcrumbContextProvider>
  22. <AccountSettingsLayout params={{}} />
  23. </BreadcrumbContextProvider>
  24. );
  25. // org from index endpoint, no `access` info
  26. rerender(
  27. <BreadcrumbContextProvider>
  28. <AccountSettingsLayout params={{}} organization={organization} />
  29. </BreadcrumbContextProvider>
  30. );
  31. expect(spy).toHaveBeenCalledWith(expect.anything(), organization.slug, {
  32. setActive: true,
  33. loadProjects: true,
  34. });
  35. expect(api).toHaveBeenCalledTimes(1);
  36. });
  37. it('does not fetch org details for SidebarDropdown', function () {
  38. const {rerender} = render(
  39. <BreadcrumbContextProvider>
  40. <AccountSettingsLayout params={{}} />
  41. </BreadcrumbContextProvider>
  42. );
  43. rerender(
  44. <BreadcrumbContextProvider>
  45. <AccountSettingsLayout params={{}} organization={TestStubs.Organization()} />
  46. </BreadcrumbContextProvider>
  47. );
  48. expect(spy).not.toHaveBeenCalledWith();
  49. expect(api).not.toHaveBeenCalled();
  50. });
  51. });