a4aca6c3a06be43064ece41e6274362f3584bcdaf621e6cc46651196ec0f54a71c9f9892e9b7ae76379cf5be24f69e27b745cd1c3040ecbdba9fc6b6fbd0e4 2.5 KB

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