29d1c548cea25a15a2a4b580b84306a92821f8200bde3b9bc812f04656224b3ffefc1711a9e3c48e3e9b9cca236c997f30526106d442dc9f695636c9cbf4a3 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. describe('Walkontable.CellCoords', function () {
  2. describe('isValid', function () {
  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: table,
  10. data: [],
  11. totalRows: 10,
  12. totalColumns: 5
  13. });
  14. it('should be false if one of the arguments is smaller than 0', function () {
  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', function () {
  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', function () {
  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', function () {
  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', function () {
  38. var cellCoords = new Walkontable.CellCoords(1, 5);
  39. var result = cellCoords.isValid(wot);
  40. expect(result).toBe(false);
  41. });
  42. });
  43. describe('isEqual', function () {
  44. it('should be equal to itself', function () {
  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', function () {
  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', function () {
  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. });