getCopyableText.spec.js 922 B

12345678910111213141516171819202122232425262728293031323334
  1. describe('Core.getCopyableText', () => {
  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 return copyable string when `copyable` option is enabled', () => {
  13. handsontable({
  14. data: Handsontable.helper.createSpreadsheetData(5, 5),
  15. copyable: true
  16. });
  17. expect(getCopyableText(0, 0)).toBe('A1');
  18. expect(getCopyableText(0, 0, 1, 2)).toBe('A1\tB1\tC1\nA2\tB2\tC2');
  19. });
  20. it('should return empty string as copyable data when `copyable` option is disabled', () => {
  21. handsontable({
  22. data: Handsontable.helper.createSpreadsheetData(5, 5),
  23. copyable: false
  24. });
  25. expect(getCopyableText(0, 0)).toBe('');
  26. expect(getCopyableText(0, 0, 1, 2)).toBe('\t\t\n\t\t');
  27. });
  28. });