stubs.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. WAGTAIL_I18N_ENABLED: true,
  50. LOCALES: [
  51. {
  52. code: 'en',
  53. display_name: 'English'
  54. },
  55. {
  56. code: 'fr',
  57. display_nam: 'French'
  58. }
  59. ],
  60. ACTIVE_LOCALE: 'en'
  61. };
  62. global.wagtailVersion = '1.6a1';
  63. global.wagtail = {};
  64. global.chooserUrls = {
  65. documentChooser: '/admin/documents/chooser/',
  66. emailLinkChooser: '/admin/choose-email-link/',
  67. anchorLinkChooser: '/admin/choose-anchor-link',
  68. embedsChooser: '/admin/embeds/chooser/',
  69. externalLinkChooser: '/admin/choose-external-link/',
  70. imageChooser: '/admin/images/chooser/',
  71. pageChooser: '/admin/choose-page/',
  72. };
  73. /* use dummy content for onload handlers just so that we can verify that we've chosen the right one */
  74. global.IMAGE_CHOOSER_MODAL_ONLOAD_HANDLERS = { type: 'image' };
  75. global.PAGE_CHOOSER_MODAL_ONLOAD_HANDLERS = { type: 'page' };
  76. global.EMBED_CHOOSER_MODAL_ONLOAD_HANDLERS = { type: 'embed' };
  77. global.DOCUMENT_CHOOSER_MODAL_ONLOAD_HANDLERS = { type: 'document' };
  78. const jQueryObj = {
  79. on: jest.fn(),
  80. off: jest.fn(),
  81. };
  82. global.jQuery = () => jQueryObj;