a7bfc81d46a335e9fcde9d46aff28be6df86e47aa132564efbcf1d385721b358208f28d0ab2e72c3a3645cacb6b73e1ddadeb8ed82410a51f1b6f52b30acba 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. describe('Core.getRowHeader', () => {
  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(getRowHeader(1)).toEqual(void 0);
  15. });
  16. it('when configured as true, should return the index incremented by 1', () => {
  17. handsontable({
  18. rowHeaders: true
  19. });
  20. expect(getRowHeader(1)).toEqual(2);
  21. });
  22. it('when configured as array, should return value at index', () => {
  23. handsontable({
  24. rowHeaders: ['One', 'Two', 'Three', 'Four', 'Five']
  25. });
  26. expect(getRowHeader(1)).toEqual('Two');
  27. });
  28. it('when configured as function, should return function output', () => {
  29. handsontable({
  30. rowHeaders(index) {
  31. return `row${index}`;
  32. }
  33. });
  34. expect(getRowHeader(1)).toEqual('row1');
  35. });
  36. it('when configured as static value, should return the value', () => {
  37. handsontable({
  38. rowHeaders: 'static'
  39. });
  40. expect(getRowHeader(1)).toEqual('static');
  41. });
  42. it('when configured as HTML value, should render that as HTML', () => {
  43. handsontable({
  44. rowHeaders(index) {
  45. return `<b>row${index}</b>`;
  46. }
  47. });
  48. expect(getRowHeader(1)).toEqual('<b>row1</b>');
  49. });
  50. it('when no argument given, should return as much row headers as there are rows', () => {
  51. handsontable({
  52. rowHeaders: true,
  53. startRows: 3
  54. });
  55. expect(getRowHeader()).toEqual([1, 2, 3]);
  56. });
  57. });