stubs.js 2.3 KB

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