stubs.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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/v2beta/documents/',
  10. IMAGES: '/admin/api/v2beta/images/',
  11. PAGES: '/admin/api/v2beta/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. },
  47. };
  48. global.wagtailVersion = '1.6a1';
  49. global.wagtail = {};
  50. global.chooserUrls = {
  51. documentChooser: '/admin/documents/chooser/',
  52. emailLinkChooser: '/admin/choose-email-link/',
  53. embedsChooser: '/admin/embeds/chooser/',
  54. externalLinkChooser: '/admin/choose-external-link/',
  55. imageChooser: '/admin/images/chooser/',
  56. pageChooser: '/admin/choose-page/',
  57. snippetChooser: '/admin/snippets/choose/',
  58. };
  59. /* use dummy content for onload handlers just so that we can verify that we've chosen the right one */
  60. global.IMAGE_CHOOSER_MODAL_ONLOAD_HANDLERS = { type: 'image' };
  61. global.PAGE_CHOOSER_MODAL_ONLOAD_HANDLERS = { type: 'page' };
  62. global.EMBED_CHOOSER_MODAL_ONLOAD_HANDLERS = { type: 'embed' };
  63. global.DOCUMENT_CHOOSER_MODAL_ONLOAD_HANDLERS = { type: 'document' };
  64. const jQueryObj = {
  65. on: jest.fn(),
  66. off: jest.fn(),
  67. };
  68. global.jQuery = () => jQueryObj;