123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. const {PERMISSIONS, RESULTS} = require('./lib/commonjs/constants');
  2. export {PERMISSIONS, RESULTS};
  3. export const openSettings = jest.fn(async () => {});
  4. export const check = jest.fn(async permission => RESULTS.GRANTED);
  5. export const request = jest.fn(async permission => RESULTS.GRANTED);
  6. const notificationOptions = [
  7. 'alert',
  8. 'badge',
  9. 'sound',
  10. 'criticalAlert',
  11. 'carPlay',
  12. // 'provisional', // excluded as it's not included in NotificationSettings
  13. ];
  14. const notificationSettings = {
  15. alert: true,
  16. badge: true,
  17. sound: true,
  18. carPlay: true,
  19. criticalAlert: true,
  20. lockScreen: true,
  21. notificationCenter: true,
  22. };
  23. export const checkNotifications = jest.fn(async () => ({
  24. status: RESULTS.GRANTED,
  25. settings: notificationSettings,
  26. }));
  27. export const requestNotifications = jest.fn(async options => ({
  28. status: RESULTS.GRANTED,
  29. settings: options
  30. .filter(option => notificationOptions.includes(option))
  31. .reduce((acc, option) => ({...acc, [option]: true}), {
  32. lockScreen: true,
  33. notificationCenter: true,
  34. }),
  35. }));
  36. export default {
  37. PERMISSIONS,
  38. RESULTS,
  39. openSettings,
  40. check,
  41. request,
  42. checkNotifications,
  43. requestNotifications,
  44. };