stubs.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. WRITE_HERE: 'Write here…',
  33. HORIZONTAL_LINE: 'Horizontal line',
  34. LINE_BREAK: 'Line break',
  35. UNDO: 'Undo',
  36. REDO: 'Redo',
  37. RELOAD_PAGE: 'Reload the page',
  38. RELOAD_EDITOR: 'Reload saved content',
  39. SHOW_LATEST_CONTENT: 'Show latest content',
  40. SHOW_ERROR: 'Show error',
  41. EDITOR_CRASH: 'The editor just crashed. Content has been reset to the last saved version.',
  42. BROKEN_LINK: 'Broken link',
  43. MISSING_DOCUMENT: 'Missing document',
  44. CLOSE: 'Close',
  45. EDIT_PAGE: 'Edit \'{title}\'',
  46. VIEW_CHILD_PAGES_OF_PAGE: 'View child pages of \'{title}\'',
  47. PAGE_EXPLORER: 'Page explorer',
  48. },
  49. };
  50. global.wagtailVersion = '1.6a1';
  51. global.wagtail = {};
  52. global.chooserUrls = {
  53. documentChooser: '/admin/documents/chooser/',
  54. emailLinkChooser: '/admin/choose-email-link/',
  55. anchorLinkChooser: '/admin/choose-anchor-link',
  56. embedsChooser: '/admin/embeds/chooser/',
  57. externalLinkChooser: '/admin/choose-external-link/',
  58. imageChooser: '/admin/images/chooser/',
  59. pageChooser: '/admin/choose-page/',
  60. snippetChooser: '/admin/snippets/choose/',
  61. };
  62. /* use dummy content for onload handlers just so that we can verify that we've chosen the right one */
  63. global.IMAGE_CHOOSER_MODAL_ONLOAD_HANDLERS = { type: 'image' };
  64. global.PAGE_CHOOSER_MODAL_ONLOAD_HANDLERS = { type: 'page' };
  65. global.EMBED_CHOOSER_MODAL_ONLOAD_HANDLERS = { type: 'embed' };
  66. global.DOCUMENT_CHOOSER_MODAL_ONLOAD_HANDLERS = { type: 'document' };
  67. const jQueryObj = {
  68. on: jest.fn(),
  69. off: jest.fn(),
  70. };
  71. global.jQuery = () => jQueryObj;