useIsSentryEmployee.spec.tsx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import {ConfigFixture} from 'sentry-fixture/config';
  2. import {UserFixture} from 'sentry-fixture/user';
  3. import {renderHook} from 'sentry-test/reactTestingLibrary';
  4. import ConfigStore from 'sentry/stores/configStore';
  5. import {useIsSentryEmployee} from 'sentry/utils/useIsSentryEmployee';
  6. describe('useIsSentryEmployee', () => {
  7. it('should return true if the user is a Sentry employee', () => {
  8. ConfigStore.loadInitialData(
  9. ConfigFixture({
  10. user: UserFixture({
  11. emails: [
  12. {
  13. email: 'jenn@sentry.io',
  14. is_verified: true,
  15. id: '1',
  16. },
  17. ],
  18. }),
  19. })
  20. );
  21. const {result} = renderHook(() => useIsSentryEmployee());
  22. expect(result.current).toBe(true);
  23. });
  24. it('should return false if the user is not a Sentry employee', () => {
  25. // Mock ConfigStore to simulate a non-Sentry employee
  26. ConfigStore.loadInitialData(
  27. ConfigFixture({
  28. user: UserFixture({
  29. emails: [
  30. {
  31. email: 'jenn@not-sentry.com',
  32. is_verified: true,
  33. id: '1',
  34. },
  35. ],
  36. }),
  37. })
  38. );
  39. const {result} = renderHook(() => useIsSentryEmployee());
  40. expect(result.current).toBe(false);
  41. });
  42. it('should return false if the email is not verified', () => {
  43. ConfigStore.loadInitialData(
  44. ConfigFixture({
  45. user: UserFixture({
  46. emails: [
  47. {
  48. email: 'jenn@sentry.io',
  49. is_verified: false,
  50. id: '1',
  51. },
  52. ],
  53. }),
  54. })
  55. );
  56. const {result} = renderHook(() => useIsSentryEmployee());
  57. expect(result.current).toBe(false);
  58. });
  59. });