stubs.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /**
  2. * Test stubs to mirror available global variables.
  3. * Those variables usually come from the back-end via templates.
  4. * See /wagtailadmin/templates/wagtailadmin/admin_base.html.
  5. */
  6. import 'element-closest';
  7. global.wagtailConfig = {
  8. ADMIN_API: {
  9. DOCUMENTS: '/admin/api/main/documents/',
  10. IMAGES: '/admin/api/main/images/',
  11. PAGES: '/admin/api/main/pages/',
  12. EXTRA_CHILDREN_PARAMETERS: '',
  13. },
  14. ADMIN_URLS: {
  15. PAGES: '/admin/pages/',
  16. },
  17. DATE_FORMATTING: {
  18. DATE_FORMAT: 'MMM. D, YYYY',
  19. SHORT_DATE_FORMAT: 'DD/MM/YYYY',
  20. },
  21. STRINGS: {
  22. DELETE: 'Delete',
  23. EDIT: 'Edit',
  24. PAGE: 'Page',
  25. PAGES: 'Pages',
  26. LOADING: 'Loading…',
  27. NO_RESULTS: 'No results',
  28. SERVER_ERROR: 'Server Error',
  29. SEE_ALL: 'See all',
  30. CLOSE_EXPLORER: 'Close explorer',
  31. ALT_TEXT: 'Alt text',
  32. DECORATIVE_IMAGE: 'Decorative image',
  33. WRITE_HERE: 'Write here…',
  34. HORIZONTAL_LINE: 'Horizontal line',
  35. LINE_BREAK: 'Line break',
  36. UNDO: 'Undo',
  37. REDO: 'Redo',
  38. RELOAD_PAGE: 'Reload the page',
  39. RELOAD_EDITOR: 'Reload saved content',
  40. SHOW_LATEST_CONTENT: 'Show latest content',
  41. SHOW_ERROR: 'Show error',
  42. EDITOR_CRASH: 'The editor just crashed. Content has been reset to the last saved version.',
  43. BROKEN_LINK: 'Broken link',
  44. MISSING_DOCUMENT: 'Missing document',
  45. CLOSE: 'Close',
  46. EDIT_PAGE: 'Edit \'{title}\'',
  47. VIEW_CHILD_PAGES_OF_PAGE: 'View child pages of \'{title}\'',
  48. PAGE_EXPLORER: 'Page explorer',
  49. SAVE: 'Save',
  50. SAVING: 'Saving...',
  51. CANCEL: 'Cancel',
  52. DELETING: 'Deleting...',
  53. SHOW_RESOLVED_COMMENTS: 'Show resolved comments',
  54. SHOW_COMMENTS: 'Show comments',
  55. REPLY: 'Reply',
  56. RETRY: 'Retry',
  57. DELETE_ERROR: 'Delete error',
  58. CONFIRM_DELETE_COMMENT: 'Are you sure?',
  59. SAVE_ERROR: 'Save error',
  60. FOCUS_COMMENT: 'Focus comment',
  61. UNFOCUS_COMMENT: 'Unfocus comment'
  62. },
  63. WAGTAIL_I18N_ENABLED: true,
  64. LOCALES: [
  65. {
  66. code: 'en',
  67. display_name: 'English'
  68. },
  69. {
  70. code: 'fr',
  71. display_nam: 'French'
  72. }
  73. ],
  74. ACTIVE_LOCALE: 'en'
  75. };
  76. global.wagtailVersion = '1.6a1';
  77. global.wagtail = {};
  78. global.chooserUrls = {
  79. documentChooser: '/admin/documents/chooser/',
  80. emailLinkChooser: '/admin/choose-email-link/',
  81. anchorLinkChooser: '/admin/choose-anchor-link',
  82. embedsChooser: '/admin/embeds/chooser/',
  83. externalLinkChooser: '/admin/choose-external-link/',
  84. imageChooser: '/admin/images/chooser/',
  85. pageChooser: '/admin/choose-page/',
  86. };
  87. /* use dummy content for onload handlers just so that we can verify that we've chosen the right one */
  88. global.IMAGE_CHOOSER_MODAL_ONLOAD_HANDLERS = { type: 'image' };
  89. global.PAGE_CHOOSER_MODAL_ONLOAD_HANDLERS = { type: 'page' };
  90. global.EMBED_CHOOSER_MODAL_ONLOAD_HANDLERS = { type: 'embed' };
  91. global.DOCUMENT_CHOOSER_MODAL_ONLOAD_HANDLERS = { type: 'document' };
  92. const jQueryObj = {
  93. on: jest.fn(),
  94. off: jest.fn(),
  95. };
  96. global.jQuery = () => jQueryObj;