organizationStore.spec.jsx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import OrganizationStore from 'sentry/stores/organizationStore';
  2. describe('OrganizationStore', function () {
  3. beforeEach(function () {
  4. OrganizationStore.reset();
  5. });
  6. it('starts with loading state', function () {
  7. expect(OrganizationStore.get()).toMatchObject({
  8. loading: true,
  9. error: null,
  10. errorType: null,
  11. organization: null,
  12. dirty: false,
  13. });
  14. });
  15. it('updates correctly', function () {
  16. const organization = TestStubs.Organization();
  17. OrganizationStore.onUpdate(organization);
  18. expect(OrganizationStore.get()).toMatchObject({
  19. loading: false,
  20. error: null,
  21. errorType: null,
  22. organization,
  23. dirty: false,
  24. });
  25. // updates
  26. organization.slug = 'a new slug';
  27. OrganizationStore.onUpdate(organization);
  28. expect(OrganizationStore.get()).toMatchObject({
  29. loading: false,
  30. error: null,
  31. errorType: null,
  32. organization,
  33. dirty: false,
  34. });
  35. });
  36. it('updates correctly from setting changes', function () {
  37. const organization = TestStubs.Organization();
  38. OrganizationStore.onUpdate(organization);
  39. expect(OrganizationStore.get()).toMatchObject({
  40. loading: false,
  41. error: null,
  42. errorType: null,
  43. organization,
  44. dirty: false,
  45. });
  46. });
  47. it('errors correctly', function () {
  48. const error = new Error('uh-oh');
  49. error.status = 404;
  50. OrganizationStore.onFetchOrgError(error);
  51. expect(OrganizationStore.get()).toMatchObject({
  52. loading: false,
  53. error,
  54. errorType: 'ORG_NOT_FOUND',
  55. organization: null,
  56. dirty: false,
  57. });
  58. });
  59. });