autocompleteRenderer.spec.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. describe('AutocompleteRenderer', () => {
  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. it('should contain down arrow glyph', (done) => {
  13. var onAfterValidate = jasmine.createSpy('onAfterValidate');
  14. handsontable({
  15. type: 'autocomplete',
  16. afterValidate: onAfterValidate
  17. });
  18. setDataAtCell(2, 2, 'string');
  19. setTimeout(() => {
  20. var 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. var 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. var 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. });