07a710519c85306f4ace2f68ee3f82815f5d5c12bf634d537fa524496530fb53f01e3ff83d5dfbd29525a4cf647128ba87b552754b529a9ae64e22847d77fe 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. describe('Walkontable.CellCoords', () => {
  2. describe('isValid', () => {
  3. var table = document.createElement('table');
  4. var wrapper = document.createElement('div');
  5. var container = document.createElement('div');
  6. wrapper.appendChild(container);
  7. container.appendChild(table);
  8. var wot = new Walkontable.Core({
  9. table,
  10. data: [],
  11. totalRows: 10,
  12. totalColumns: 5
  13. });
  14. it('should be false if one of the arguments is smaller than 0', () => {
  15. var cellCoords = new Walkontable.CellCoords(-1, 0);
  16. var result = cellCoords.isValid(wot);
  17. expect(result).toBe(false);
  18. cellCoords = new Walkontable.CellCoords(0, -1);
  19. result = cellCoords.isValid(wot);
  20. expect(result).toBe(false);
  21. });
  22. it('should be true if row is within the total number of rows', () => {
  23. var cellCoords = new Walkontable.CellCoords(9, 1);
  24. var result = cellCoords.isValid(wot);
  25. expect(result).toBe(true);
  26. });
  27. it('should be false if row is greater than total number of rows', () => {
  28. var cellCoords = new Walkontable.CellCoords(10, 1);
  29. var result = cellCoords.isValid(wot);
  30. expect(result).toBe(false);
  31. });
  32. it('should be true if column is within the total number of columns', () => {
  33. var cellCoords = new Walkontable.CellCoords(1, 4);
  34. var result = cellCoords.isValid(wot);
  35. expect(result).toBe(true);
  36. });
  37. it('should be false if column is greater than total number of columns', () => {
  38. var cellCoords = new Walkontable.CellCoords(1, 5);
  39. var result = cellCoords.isValid(wot);
  40. expect(result).toBe(false);
  41. });
  42. });
  43. describe('isEqual', () => {
  44. it('should be equal to itself', () => {
  45. var cellCoords = new Walkontable.CellCoords(1, 1);
  46. var result = cellCoords.isEqual(cellCoords);
  47. expect(result).toBe(true);
  48. });
  49. it('should be equal to another instance with the same row and column', () => {
  50. var cellCoords = new Walkontable.CellCoords(1, 1);
  51. var cellCoords2 = new Walkontable.CellCoords(1, 1);
  52. var result = cellCoords.isEqual(cellCoords2);
  53. expect(result).toBe(true);
  54. });
  55. it('should not be equal to an instance with different row or column', () => {
  56. var cellCoords = new Walkontable.CellCoords(1, 1);
  57. var cellCoords2 = new Walkontable.CellCoords(2, 1);
  58. var result = cellCoords.isEqual(cellCoords2);
  59. expect(result).toBe(false);
  60. });
  61. });
  62. });