publicAPI.spec.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. describe('Public API', () => {
  2. var id = 'testContainer';
  3. beforeEach(function() {
  4. this.$container = $(`<div id="${id}"></div>`).appendTo('body');
  5. });
  6. afterEach(function() {
  7. if (this.$container) {
  8. destroy();
  9. this.$container.remove();
  10. }
  11. });
  12. describe('Plugins', () => {
  13. it('should expose static method for registering external plugins', () => {
  14. expect(Handsontable.plugins.registerPlugin).toBeFunction();
  15. });
  16. it('should expose BasePlugin class', () => {
  17. expect(Handsontable.plugins.BasePlugin).toBeFunction();
  18. });
  19. it('should expose all registered plugin classes', () => {
  20. expect(Handsontable.plugins.AutoColumnSize).toBeFunction();
  21. expect(Handsontable.plugins.AutoRowSize).toBeFunction();
  22. expect(Handsontable.plugins.ColumnSorting).toBeFunction();
  23. expect(Handsontable.plugins.Comments).toBeFunction();
  24. expect(Handsontable.plugins.ContextMenu).toBeFunction();
  25. expect(Handsontable.plugins.ContextMenuCopyPaste).toBeFunction();
  26. expect(Handsontable.plugins.DragToScroll).toBeFunction();
  27. expect(Handsontable.plugins.ManualColumnFreeze).toBeFunction();
  28. expect(Handsontable.plugins.ManualColumnResize).toBeFunction();
  29. expect(Handsontable.plugins.ManualRowResize).toBeFunction();
  30. expect(Handsontable.plugins.MultipleSelectionHandles).toBeFunction();
  31. expect(Handsontable.plugins.TouchScroll).toBeFunction();
  32. });
  33. });
  34. describe('Editors', () => {
  35. it('should expose static method for registering external editors', () => {
  36. expect(Handsontable.editors.registerEditor).toBeFunction();
  37. });
  38. it('should expose static method for retrieving registered editors', () => {
  39. expect(Handsontable.editors.getEditor).toBeFunction();
  40. });
  41. it('should expose BaseEditor class', () => {
  42. expect(Handsontable.editors.BaseEditor).toBeFunction();
  43. });
  44. it('should expose all registered editor classes', () => {
  45. expect(Handsontable.editors.AutocompleteEditor).toBeFunction();
  46. expect(Handsontable.editors.CheckboxEditor).toBeFunction();
  47. expect(Handsontable.editors.DateEditor).toBeFunction();
  48. expect(Handsontable.editors.DropdownEditor).toBeFunction();
  49. expect(Handsontable.editors.HandsontableEditor).toBeFunction();
  50. expect(Handsontable.editors.MobileEditor).toBeFunction();
  51. expect(Handsontable.editors.NumericEditor).toBeFunction();
  52. expect(Handsontable.editors.PasswordEditor).toBeFunction();
  53. expect(Handsontable.editors.SelectEditor).toBeFunction();
  54. expect(Handsontable.editors.TextEditor).toBeFunction();
  55. });
  56. });
  57. describe('Renderers', () => {
  58. it('should expose static method for registering external renderers', () => {
  59. expect(Handsontable.renderers.registerRenderer).toBeFunction();
  60. });
  61. it('should expose static method for retrieving registered renderers', () => {
  62. expect(Handsontable.renderers.getRenderer).toBeFunction();
  63. });
  64. it('should expose BaseRenderer class', () => {
  65. expect(Handsontable.renderers.BaseRenderer).toBeFunction();
  66. });
  67. it('should expose all registered renderer functions', () => {
  68. expect(Handsontable.renderers.AutocompleteRenderer).toBeFunction();
  69. expect(Handsontable.renderers.CheckboxRenderer).toBeFunction();
  70. expect(Handsontable.renderers.HtmlRenderer).toBeFunction();
  71. expect(Handsontable.renderers.NumericRenderer).toBeFunction();
  72. expect(Handsontable.renderers.PasswordRenderer).toBeFunction();
  73. expect(Handsontable.renderers.TextRenderer).toBeFunction();
  74. });
  75. });
  76. describe('Validators', () => {
  77. it('should expose static method for registering external validators', () => {
  78. expect(Handsontable.validators.registerValidator).toBeFunction();
  79. });
  80. it('should expose static method for retrieving registered validators', () => {
  81. expect(Handsontable.validators.getValidator).toBeFunction();
  82. });
  83. it('should expose all registered validator functions', () => {
  84. expect(Handsontable.validators.AutocompleteValidator).toBeFunction();
  85. expect(Handsontable.validators.DateValidator).toBeFunction();
  86. expect(Handsontable.validators.NumericValidator).toBeFunction();
  87. expect(Handsontable.validators.TimeValidator).toBeFunction();
  88. });
  89. });
  90. describe('CellTypes', () => {
  91. it('should expose static method for registering external cell types', () => {
  92. expect(Handsontable.cellTypes.registerCellType).toBeFunction();
  93. });
  94. it('should expose static method for retrieving registered cell types', () => {
  95. expect(Handsontable.cellTypes.getCellType).toBeFunction();
  96. });
  97. it('should expose all registered cell type objects', () => {
  98. expect(Handsontable.cellTypes.autocomplete.editor).toBe(Handsontable.editors.AutocompleteEditor);
  99. expect(Handsontable.cellTypes.autocomplete.renderer).toBe(Handsontable.renderers.AutocompleteRenderer);
  100. expect(Handsontable.cellTypes.autocomplete.validator).toBe(Handsontable.validators.AutocompleteValidator);
  101. expect(Handsontable.cellTypes.checkbox.editor).toBe(Handsontable.editors.CheckboxEditor);
  102. expect(Handsontable.cellTypes.checkbox.renderer).toBe(Handsontable.renderers.CheckboxRenderer);
  103. expect(Handsontable.cellTypes.checkbox.validator).not.toBeDefined();
  104. expect(Handsontable.cellTypes.date.editor).toBe(Handsontable.editors.DateEditor);
  105. expect(Handsontable.cellTypes.date.renderer).toBe(Handsontable.renderers.AutocompleteRenderer);
  106. expect(Handsontable.cellTypes.date.validator).toBe(Handsontable.validators.DateValidator);
  107. expect(Handsontable.cellTypes.dropdown.editor).toBe(Handsontable.editors.DropdownEditor);
  108. expect(Handsontable.cellTypes.dropdown.renderer).toBe(Handsontable.renderers.AutocompleteRenderer);
  109. expect(Handsontable.cellTypes.dropdown.validator).toBe(Handsontable.validators.AutocompleteValidator);
  110. expect(Handsontable.cellTypes.handsontable.editor).toBe(Handsontable.editors.HandsontableEditor);
  111. expect(Handsontable.cellTypes.handsontable.renderer).toBe(Handsontable.renderers.AutocompleteRenderer);
  112. expect(Handsontable.cellTypes.handsontable.validator).not.toBeDefined();
  113. expect(Handsontable.cellTypes.numeric.editor).toBe(Handsontable.editors.NumericEditor);
  114. expect(Handsontable.cellTypes.numeric.renderer).toBe(Handsontable.renderers.NumericRenderer);
  115. expect(Handsontable.cellTypes.numeric.validator).toBe(Handsontable.validators.NumericValidator);
  116. expect(Handsontable.cellTypes.password.editor).toBe(Handsontable.editors.PasswordEditor);
  117. expect(Handsontable.cellTypes.password.renderer).toBe(Handsontable.renderers.PasswordRenderer);
  118. expect(Handsontable.cellTypes.password.validator).not.toBeDefined();
  119. expect(Handsontable.cellTypes.text.editor).toBe(Handsontable.editors.TextEditor);
  120. expect(Handsontable.cellTypes.text.renderer).toBe(Handsontable.renderers.TextRenderer);
  121. expect(Handsontable.cellTypes.text.validator).not.toBeDefined();
  122. expect(Handsontable.cellTypes.time.editor).toBe(Handsontable.editors.TextEditor);
  123. expect(Handsontable.cellTypes.time.renderer).toBe(Handsontable.renderers.TextRenderer);
  124. expect(Handsontable.cellTypes.time.validator).toBe(Handsontable.validators.TimeValidator);
  125. });
  126. });
  127. });