autocompleteRenderer.spec.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. describe('AutocompleteRenderer', () => {
  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. it('should contain down arrow glyph', (done) => {
  13. const onAfterValidate = jasmine.createSpy('onAfterValidate');
  14. handsontable({
  15. type: 'autocomplete',
  16. afterValidate: onAfterValidate
  17. });
  18. setDataAtCell(2, 2, 'string');
  19. setTimeout(() => {
  20. const html = getCell(2, 2).innerHTML;
  21. expect(html).toContain('string');
  22. expect(html).toContain('\u25BC');
  23. done();
  24. }, 100);
  25. });
  26. it('should open cell editor after clicking on arrow glyph', () => {
  27. const hot = handsontable({
  28. type: 'autocomplete'
  29. });
  30. selectCell(0, 0);
  31. expect(hot.getActiveEditor().isOpened()).toBe(false);
  32. $(getCell(0, 0)).find('.htAutocompleteArrow').simulate('mousedown');
  33. expect(hot.getActiveEditor().isOpened()).toBe(true);
  34. });
  35. it('should open cell editor after clicking on arrow glyph, after the table has been destroyed and reinitialized (#1367)', () => {
  36. let hot = handsontable({
  37. type: 'autocomplete'
  38. });
  39. destroy();
  40. hot = handsontable({
  41. type: 'autocomplete'
  42. });
  43. selectCell(0, 0);
  44. expect(hot.getActiveEditor().isOpened()).toBe(false);
  45. $(getCell(0, 0)).find('.htAutocompleteArrow').simulate('mousedown');
  46. expect(hot.getActiveEditor().isOpened()).toBe(true);
  47. });
  48. it('should prepend the autocomplete arrow at the start of the cell element (#5124)', () => {
  49. handsontable({
  50. type: 'autocomplete'
  51. });
  52. const $contents = $(getCell(0, 0)).contents();
  53. expect($contents.eq(0).hasClass('htAutocompleteArrow')).toBe(true);
  54. });
  55. });