08170aecf944219eca9db8884e4a34aeaba932e232d0677f06fd29ab849618813f67bd4d3120d3ad22a5d72b86fb04b42c04b038e2eaa62d02cdad2b091bec 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. describe('Core.getColHeader', () => {
  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('when not configured, should return undefined', () => {
  13. handsontable();
  14. expect(getColHeader(1)).toBe(null);
  15. });
  16. it('when configured as true, should return the Excel-style column title', () => {
  17. handsontable({
  18. colHeaders: true
  19. });
  20. expect(getColHeader(30)).toEqual('AE');
  21. });
  22. it('when configured as array, should return value at index', () => {
  23. handsontable({
  24. colHeaders: ['One', 'Two', 'Three', 'Four', 'Five']
  25. });
  26. expect(getColHeader(1)).toEqual('Two');
  27. });
  28. it('when configured as function, should return function output', () => {
  29. handsontable({
  30. colHeaders(index) {
  31. return `col${index}`;
  32. }
  33. });
  34. expect(getColHeader(1)).toEqual('col1');
  35. });
  36. it('when configured as static value, should return the value', () => {
  37. handsontable({
  38. colHeaders: 'static'
  39. });
  40. expect(getColHeader(1)).toEqual('static');
  41. });
  42. it('when configured as HTML value, should render that as HTML', () => {
  43. handsontable({
  44. colHeaders(index) {
  45. return `<b>col${index}</b>`;
  46. }
  47. });
  48. expect(getColHeader(1)).toEqual('<b>col1</b>');
  49. });
  50. it('when no argument given, should return as much column headers as there are columns', () => {
  51. handsontable({
  52. colHeaders: true,
  53. startCols: 3
  54. });
  55. expect(getColHeader()).toEqual(['A', 'B', 'C']);
  56. });
  57. });