emails.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. const MOCK_DELAY = 1000
  2. const fakeUsersData = [
  3. {
  4. affiliation: {
  5. institution: {
  6. confirmed: true,
  7. name: 'Overleaf',
  8. },
  9. licence: 'pro_plus',
  10. },
  11. confirmedAt: '2022-03-09T10:59:44.139Z',
  12. email: 'foo@overleaf.com',
  13. default: true,
  14. },
  15. {
  16. confirmedAt: '2022-03-10T10:59:44.139Z',
  17. email: 'bar@overleaf.com',
  18. default: false,
  19. },
  20. {
  21. affiliation: {
  22. institution: {
  23. confirmed: true,
  24. name: 'Overleaf',
  25. },
  26. licence: 'pro_plus',
  27. department: 'Art & Art History',
  28. role: 'Postdoc',
  29. },
  30. email: 'baz@overleaf.com',
  31. default: false,
  32. },
  33. {
  34. email: 'qux@overleaf.com',
  35. default: false,
  36. },
  37. ]
  38. export function defaultSetupMocks(fetchMock) {
  39. fetchMock
  40. .get(/\/user\/emails/, fakeUsersData, { delay: MOCK_DELAY })
  41. .post(/\/user\/emails\/*/, 200, {
  42. delay: MOCK_DELAY,
  43. })
  44. }
  45. export function errorsMocks(fetchMock) {
  46. fetchMock
  47. .get(/\/user\/emails/, fakeUsersData, { delay: MOCK_DELAY })
  48. .post(/\/user\/emails\/*/, 500)
  49. }
  50. export function setDefaultMeta() {
  51. window.metaAttributesCache = window.metaAttributesCache || new Map()
  52. window.metaAttributesCache.set('ol-ExposedSettings', {
  53. hasAffiliationsFeature: true,
  54. })
  55. }