publicAPI.spec.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. describe('Public API', () => {
  2. const 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.CopyPaste).toBeFunction();
  26. expect(Handsontable.plugins.CustomBorders).toBeFunction();
  27. expect(Handsontable.plugins.DragToScroll).toBeFunction();
  28. expect(Handsontable.plugins.ManualColumnFreeze).toBeFunction();
  29. expect(Handsontable.plugins.ManualColumnResize).toBeFunction();
  30. expect(Handsontable.plugins.ManualRowResize).toBeFunction();
  31. expect(Handsontable.plugins.MultipleSelectionHandles).toBeFunction();
  32. expect(Handsontable.plugins.TouchScroll).toBeFunction();
  33. expect(Handsontable.plugins.UndoRedo).toBeFunction();
  34. });
  35. });
  36. describe('Editors', () => {
  37. it('should expose static method for registering external editors', () => {
  38. expect(Handsontable.editors.registerEditor).toBeFunction();
  39. });
  40. it('should expose static method for retrieving registered editors', () => {
  41. expect(Handsontable.editors.getEditor).toBeFunction();
  42. });
  43. it('should expose BaseEditor class', () => {
  44. expect(Handsontable.editors.BaseEditor).toBeFunction();
  45. });
  46. it('should expose all registered editor classes', () => {
  47. expect(Handsontable.editors.AutocompleteEditor).toBeFunction();
  48. expect(Handsontable.editors.CheckboxEditor).toBeFunction();
  49. expect(Handsontable.editors.DateEditor).toBeFunction();
  50. expect(Handsontable.editors.DropdownEditor).toBeFunction();
  51. expect(Handsontable.editors.HandsontableEditor).toBeFunction();
  52. expect(Handsontable.editors.NumericEditor).toBeFunction();
  53. expect(Handsontable.editors.PasswordEditor).toBeFunction();
  54. expect(Handsontable.editors.SelectEditor).toBeFunction();
  55. expect(Handsontable.editors.TextEditor).toBeFunction();
  56. });
  57. });
  58. describe('Renderers', () => {
  59. it('should expose static method for registering external renderers', () => {
  60. expect(Handsontable.renderers.registerRenderer).toBeFunction();
  61. });
  62. it('should expose static method for retrieving registered renderers', () => {
  63. expect(Handsontable.renderers.getRenderer).toBeFunction();
  64. });
  65. it('should expose BaseRenderer class', () => {
  66. expect(Handsontable.renderers.BaseRenderer).toBeFunction();
  67. });
  68. it('should expose all registered renderer functions', () => {
  69. expect(Handsontable.renderers.AutocompleteRenderer).toBeFunction();
  70. expect(Handsontable.renderers.CheckboxRenderer).toBeFunction();
  71. expect(Handsontable.renderers.HtmlRenderer).toBeFunction();
  72. expect(Handsontable.renderers.NumericRenderer).toBeFunction();
  73. expect(Handsontable.renderers.PasswordRenderer).toBeFunction();
  74. expect(Handsontable.renderers.TextRenderer).toBeFunction();
  75. });
  76. });
  77. describe('Validators', () => {
  78. it('should expose static method for registering external validators', () => {
  79. expect(Handsontable.validators.registerValidator).toBeFunction();
  80. });
  81. it('should expose static method for retrieving registered validators', () => {
  82. expect(Handsontable.validators.getValidator).toBeFunction();
  83. });
  84. it('should expose all registered validator functions', () => {
  85. expect(Handsontable.validators.AutocompleteValidator).toBeFunction();
  86. expect(Handsontable.validators.DateValidator).toBeFunction();
  87. expect(Handsontable.validators.NumericValidator).toBeFunction();
  88. expect(Handsontable.validators.TimeValidator).toBeFunction();
  89. });
  90. });
  91. describe('CellTypes', () => {
  92. it('should expose static method for registering external cell types', () => {
  93. expect(Handsontable.cellTypes.registerCellType).toBeFunction();
  94. });
  95. it('should expose static method for retrieving registered cell types', () => {
  96. expect(Handsontable.cellTypes.getCellType).toBeFunction();
  97. });
  98. it('should expose all registered cell type objects', () => {
  99. expect(Handsontable.cellTypes.autocomplete.editor).toBe(Handsontable.editors.AutocompleteEditor);
  100. expect(Handsontable.cellTypes.autocomplete.renderer).toBe(Handsontable.renderers.AutocompleteRenderer);
  101. expect(Handsontable.cellTypes.autocomplete.validator).toBe(Handsontable.validators.AutocompleteValidator);
  102. expect(Handsontable.cellTypes.checkbox.editor).toBe(Handsontable.editors.CheckboxEditor);
  103. expect(Handsontable.cellTypes.checkbox.renderer).toBe(Handsontable.renderers.CheckboxRenderer);
  104. expect(Handsontable.cellTypes.checkbox.validator).not.toBeDefined();
  105. expect(Handsontable.cellTypes.date.editor).toBe(Handsontable.editors.DateEditor);
  106. expect(Handsontable.cellTypes.date.renderer).toBe(Handsontable.renderers.AutocompleteRenderer);
  107. expect(Handsontable.cellTypes.date.validator).toBe(Handsontable.validators.DateValidator);
  108. expect(Handsontable.cellTypes.dropdown.editor).toBe(Handsontable.editors.DropdownEditor);
  109. expect(Handsontable.cellTypes.dropdown.renderer).toBe(Handsontable.renderers.AutocompleteRenderer);
  110. expect(Handsontable.cellTypes.dropdown.validator).toBe(Handsontable.validators.AutocompleteValidator);
  111. expect(Handsontable.cellTypes.handsontable.editor).toBe(Handsontable.editors.HandsontableEditor);
  112. expect(Handsontable.cellTypes.handsontable.renderer).toBe(Handsontable.renderers.AutocompleteRenderer);
  113. expect(Handsontable.cellTypes.handsontable.validator).not.toBeDefined();
  114. expect(Handsontable.cellTypes.numeric.editor).toBe(Handsontable.editors.NumericEditor);
  115. expect(Handsontable.cellTypes.numeric.renderer).toBe(Handsontable.renderers.NumericRenderer);
  116. expect(Handsontable.cellTypes.numeric.validator).toBe(Handsontable.validators.NumericValidator);
  117. expect(Handsontable.cellTypes.password.editor).toBe(Handsontable.editors.PasswordEditor);
  118. expect(Handsontable.cellTypes.password.renderer).toBe(Handsontable.renderers.PasswordRenderer);
  119. expect(Handsontable.cellTypes.password.validator).not.toBeDefined();
  120. expect(Handsontable.cellTypes.text.editor).toBe(Handsontable.editors.TextEditor);
  121. expect(Handsontable.cellTypes.text.renderer).toBe(Handsontable.renderers.TextRenderer);
  122. expect(Handsontable.cellTypes.text.validator).not.toBeDefined();
  123. expect(Handsontable.cellTypes.time.editor).toBe(Handsontable.editors.TextEditor);
  124. expect(Handsontable.cellTypes.time.renderer).toBe(Handsontable.renderers.TextRenderer);
  125. expect(Handsontable.cellTypes.time.validator).toBe(Handsontable.validators.TimeValidator);
  126. });
  127. });
  128. describe('Helpers', () => {
  129. it('should expose all registered helpers', () => {
  130. expect(Handsontable.dom.addClass).toBeFunction();
  131. expect(Handsontable.dom.addEvent).toBeFunction();
  132. expect(Handsontable.dom.closest).toBeFunction();
  133. expect(Handsontable.dom.closestDown).toBeFunction();
  134. expect(Handsontable.dom.empty).toBeFunction();
  135. expect(Handsontable.dom.fastInnerHTML).toBeFunction();
  136. expect(Handsontable.dom.fastInnerText).toBeFunction();
  137. expect(Handsontable.dom.getCaretPosition).toBeFunction();
  138. expect(Handsontable.dom.getComputedStyle).toBeFunction();
  139. expect(Handsontable.dom.getCssTransform).toBeFunction();
  140. expect(Handsontable.dom.getParent).toBeFunction();
  141. expect(Handsontable.dom.getScrollLeft).toBeFunction();
  142. expect(Handsontable.dom.getScrollTop).toBeFunction();
  143. expect(Handsontable.dom.getScrollableElement).toBeFunction();
  144. expect(Handsontable.dom.getScrollbarWidth).toBeFunction();
  145. expect(Handsontable.dom.getSelectionEndPosition).toBeFunction();
  146. expect(Handsontable.dom.getSelectionText).toBeFunction();
  147. expect(Handsontable.dom.getStyle).toBeFunction();
  148. expect(Handsontable.dom.getTrimmingContainer).toBeFunction();
  149. expect(Handsontable.dom.getWindowScrollLeft).toBeFunction();
  150. expect(Handsontable.dom.getWindowScrollTop).toBeFunction();
  151. expect(Handsontable.dom.hasClass).toBeFunction();
  152. expect(Handsontable.dom.hasHorizontalScrollbar).toBeFunction();
  153. expect(Handsontable.dom.hasVerticalScrollbar).toBeFunction();
  154. expect(Handsontable.dom.index).toBeFunction();
  155. expect(Handsontable.dom.innerHeight).toBeFunction();
  156. expect(Handsontable.dom.innerWidth).toBeFunction();
  157. expect(Handsontable.dom.isChildOf).toBeFunction();
  158. expect(Handsontable.dom.isChildOfWebComponentTable).toBeFunction();
  159. expect(Handsontable.dom.isImmediatePropagationStopped).toBeFunction();
  160. expect(Handsontable.dom.isInput).toBeFunction();
  161. expect(Handsontable.dom.isLeftClick).toBeFunction();
  162. expect(Handsontable.dom.isRightClick).toBeFunction();
  163. expect(Handsontable.dom.isVisible).toBeFunction();
  164. expect(Handsontable.dom.offset).toBeFunction();
  165. expect(Handsontable.dom.outerHeight).toBeFunction();
  166. expect(Handsontable.dom.outerWidth).toBeFunction();
  167. expect(Handsontable.dom.overlayContainsElement).toBeFunction();
  168. expect(Handsontable.dom.pageX).toBeFunction();
  169. expect(Handsontable.dom.pageY).toBeFunction();
  170. expect(Handsontable.dom.polymerUnwrap).toBeFunction();
  171. expect(Handsontable.dom.polymerWrap).toBeFunction();
  172. expect(Handsontable.dom.removeClass).toBeFunction();
  173. expect(Handsontable.dom.removeEvent).toBeFunction();
  174. expect(Handsontable.dom.removeTextNodes).toBeFunction();
  175. expect(Handsontable.dom.resetCssTransform).toBeFunction();
  176. expect(Handsontable.dom.setCaretPosition).toBeFunction();
  177. expect(Handsontable.dom.setOverlayPosition).toBeFunction();
  178. expect(Handsontable.dom.stopImmediatePropagation).toBeFunction();
  179. expect(Handsontable.dom.stopPropagation).toBeFunction();
  180. });
  181. });
  182. });