From 3b04280c84225d55356392281916ebc5adfed7e1 Mon Sep 17 00:00:00 2001 From: Alain Dumesny Date: Sun, 26 Mar 2023 10:46:31 -0700 Subject: [PATCH] test partial fix * fix #2232 test cases update for first issues (now correct) but second parts doesn't seem right... need to spend time debugging this later --- spec/gridstack-spec.ts | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/spec/gridstack-spec.ts b/spec/gridstack-spec.ts index a2aa604c9..911606d0e 100644 --- a/spec/gridstack-spec.ts +++ b/spec/gridstack-spec.ts @@ -350,14 +350,31 @@ describe('gridstack', function() { expect(parseInt(el2.getAttribute('gs-w'))).toBe(4); expect(parseInt(el2.getAttribute('gs-h'))).toBe(4); - expect(parseInt(el3.getAttribute('gs-x'))).toBe(0); - expect(parseInt(el3.getAttribute('gs-y'))).toBe(6); // ??? keep same row, but might more intuitive higher - expect(parseInt(el3.getAttribute('gs-w'))).toBe(1); // ??? could take entire width if it did above + // remembers autoPlacement so finds next slot on 12 layout after 4x2 + 4x4 + expect(parseInt(el3.getAttribute('gs-x'))).toBe(8); + expect(parseInt(el3.getAttribute('gs-y'))).toBe(0); + expect(parseInt(el3.getAttribute('gs-w'))).toBe(1); expect(parseInt(el3.getAttribute('gs-h'))).toBe(1); - // back to 1 column, move item2 to beginning to [3][1][2] vertically + // back to 1 column grid.column(1); expect(grid.getColumn()).toBe(1); + expect(parseInt(el1.getAttribute('gs-x'))).toBe(0); + expect(parseInt(el1.getAttribute('gs-y'))).toBe(0); + expect(parseInt(el1.getAttribute('gs-w'))).toBe(1); + expect(parseInt(el1.getAttribute('gs-h'))).toBe(2); + + expect(parseInt(el2.getAttribute('gs-x'))).toBe(0); + expect(parseInt(el2.getAttribute('gs-y'))).toBe(2); + expect(parseInt(el2.getAttribute('gs-w'))).toBe(1); + expect(parseInt(el2.getAttribute('gs-h'))).toBe(4); + + expect(parseInt(el3.getAttribute('gs-x'))).toBe(0); + expect(parseInt(el3.getAttribute('gs-y'))).toBe(6); + expect(parseInt(el3.getAttribute('gs-w'))).toBe(1); + expect(parseInt(el3.getAttribute('gs-h'))).toBe(1); + + // move item2 to beginning to [3][1][2] vertically grid.update(el3, {x:0, y:0}); expect(parseInt(el3.getAttribute('gs-x'))).toBe(0); expect(parseInt(el3.getAttribute('gs-y'))).toBe(0); @@ -377,7 +394,7 @@ describe('gridstack', function() { // back to 12 column, el3 to be beginning still, but [1][2] to be in 1 columns still but wide 4x2 and 4x still grid.column(12); expect(grid.getColumn()).toBe(12); - expect(parseInt(el3.getAttribute('gs-x'))).toBe(0); + expect(parseInt(el3.getAttribute('gs-x'))).toBe(0); // 8 TEST WHY expect(parseInt(el3.getAttribute('gs-y'))).toBe(0); expect(parseInt(el3.getAttribute('gs-w'))).toBe(1); expect(parseInt(el3.getAttribute('gs-h'))).toBe(1); @@ -397,7 +414,7 @@ describe('gridstack', function() { grid.column(2); expect(grid.getColumn()).toBe(2); - expect(parseInt(el3.getAttribute('gs-x'))).toBe(0); + expect(parseInt(el3.getAttribute('gs-x'))).toBe(0); // 1 TEST WHY expect(parseInt(el3.getAttribute('gs-y'))).toBe(0); expect(parseInt(el3.getAttribute('gs-w'))).toBe(1); // 1 as we scaled from 12 columns expect(parseInt(el3.getAttribute('gs-h'))).toBe(1);