@@ -14,7 +14,7 @@ describe('gridstack engine', function() {
14
14
15
15
beforeAll ( function ( ) {
16
16
engine = new GridStackUI . Engine ( 12 ) ;
17
- } )
17
+ } ) ;
18
18
19
19
it ( 'should be setup properly' , function ( ) {
20
20
expect ( engine . width ) . toEqual ( 12 ) ;
@@ -29,7 +29,7 @@ describe('gridstack engine', function() {
29
29
30
30
beforeAll ( function ( ) {
31
31
engine = new GridStackUI . Engine ( 12 ) ;
32
- } )
32
+ } ) ;
33
33
34
34
it ( 'should prepare a node' , function ( ) {
35
35
expect ( engine . _prepareNode ( { } , false ) ) . toEqual ( jasmine . objectContaining ( { x : 0 , y : 0 , width : 1 , height : 1 } ) ) ;
@@ -57,7 +57,7 @@ describe('gridstack engine', function() {
57
57
engine . nodes = [
58
58
engine . _prepareNode ( { x : 3 , y : 2 , width : 3 , height : 2 } )
59
59
] ;
60
- } )
60
+ } ) ;
61
61
62
62
it ( 'should be true' , function ( ) {
63
63
expect ( engine . isAreaEmpty ( 0 , 0 , 3 , 2 ) ) . toEqual ( true ) ;
@@ -108,14 +108,14 @@ describe('gridstack engine', function() {
108
108
} ) ;
109
109
} ) ;
110
110
111
- describe ( 'test batchUpdate/commit' , function ( ) {
111
+ describe ( 'test batchUpdate/commit' , function ( ) {
112
112
var engine ;
113
113
114
- beforeAll ( function ( ) {
115
- engine = new GridStackUI . Engine ( 12 )
114
+ beforeAll ( function ( ) {
115
+ engine = new GridStackUI . Engine ( 12 ) ;
116
116
} ) ;
117
117
118
- it ( 'should work on not float grids' , function ( ) {
118
+ it ( 'should work on not float grids' , function ( ) {
119
119
expect ( engine . float ) . toEqual ( false ) ;
120
120
engine . batchUpdate ( ) ;
121
121
expect ( engine . _updateCounter ) . toBeGreaterThan ( 0 ) ;
@@ -126,14 +126,14 @@ describe('gridstack engine', function() {
126
126
} ) ;
127
127
} ) ;
128
128
129
- describe ( 'test batchUpdate/commit' , function ( ) {
129
+ describe ( 'test batchUpdate/commit' , function ( ) {
130
130
var engine ;
131
131
132
- beforeAll ( function ( ) {
133
- engine = new GridStackUI . Engine ( 12 , null , true )
132
+ beforeAll ( function ( ) {
133
+ engine = new GridStackUI . Engine ( 12 , null , true ) ;
134
134
} ) ;
135
135
136
- it ( 'should work on float grids' , function ( ) {
136
+ it ( 'should work on float grids' , function ( ) {
137
137
expect ( engine . float ) . toEqual ( true ) ;
138
138
engine . batchUpdate ( ) ;
139
139
expect ( engine . _updateCounter ) . toBeGreaterThan ( 0 ) ;
@@ -150,8 +150,8 @@ describe('gridstack engine', function() {
150
150
151
151
beforeEach ( function ( ) {
152
152
spy = {
153
- callback : function ( ) { }
154
- }
153
+ callback : function ( ) { }
154
+ } ;
155
155
spyOn ( spy , 'callback' ) ;
156
156
157
157
engine = new GridStackUI . Engine ( 12 , spy . callback , true ) ;
@@ -204,19 +204,19 @@ describe('gridstack engine', function() {
204
204
} ) ;
205
205
} ) ;
206
206
207
- describe ( 'test _packNodes' , function ( ) {
208
- describe ( 'using not float mode' , function ( ) {
207
+ describe ( 'test _packNodes' , function ( ) {
208
+ describe ( 'using not float mode' , function ( ) {
209
209
var engine ;
210
210
211
- var findNode = function ( engine , id ) {
212
- return _ . find ( engine . nodes , function ( i ) { return i . _id === id } ) ;
213
- }
211
+ var findNode = function ( engine , id ) {
212
+ return _ . find ( engine . nodes , function ( i ) { return i . _id === id ; } ) ;
213
+ } ;
214
214
215
- beforeEach ( function ( ) {
215
+ beforeEach ( function ( ) {
216
216
engine = new GridStackUI . Engine ( 12 , null , false ) ;
217
217
} ) ;
218
218
219
- it ( 'shouldn\'t pack one node with y coord eq 0' , function ( ) {
219
+ it ( 'shouldn\'t pack one node with y coord eq 0' , function ( ) {
220
220
engine . nodes = [
221
221
{ x : 0 , y : 0 , width : 1 , height : 1 , _id : 1 } ,
222
222
] ;
@@ -227,7 +227,7 @@ describe('gridstack engine', function() {
227
227
expect ( findNode ( engine , 1 ) . _dirty ) . toBeFalsy ( ) ;
228
228
} ) ;
229
229
230
- it ( 'should pack one node correctly' , function ( ) {
230
+ it ( 'should pack one node correctly' , function ( ) {
231
231
engine . nodes = [
232
232
{ x : 0 , y : 1 , width : 1 , height : 1 , _id : 1 } ,
233
233
] ;
@@ -237,7 +237,7 @@ describe('gridstack engine', function() {
237
237
expect ( findNode ( engine , 1 ) ) . toEqual ( jasmine . objectContaining ( { x : 0 , y : 0 , width : 1 , height : 1 , _dirty : true } ) ) ;
238
238
} ) ;
239
239
240
- it ( 'should pack nodes correctly' , function ( ) {
240
+ it ( 'should pack nodes correctly' , function ( ) {
241
241
engine . nodes = [
242
242
{ x : 0 , y : 1 , width : 1 , height : 1 , _id : 1 } ,
243
243
{ x : 0 , y : 5 , width : 1 , height : 1 , _id : 2 } ,
@@ -249,7 +249,7 @@ describe('gridstack engine', function() {
249
249
expect ( findNode ( engine , 2 ) ) . toEqual ( jasmine . objectContaining ( { x : 0 , y : 1 , width : 1 , height : 1 , _dirty : true } ) ) ;
250
250
} ) ;
251
251
252
- it ( 'should pack nodes correctly' , function ( ) {
252
+ it ( 'should pack nodes correctly' , function ( ) {
253
253
engine . nodes = [
254
254
{ x : 0 , y : 5 , width : 1 , height : 1 , _id : 1 } ,
255
255
{ x : 0 , y : 1 , width : 1 , height : 1 , _id : 2 } ,
@@ -261,7 +261,7 @@ describe('gridstack engine', function() {
261
261
expect ( findNode ( engine , 1 ) ) . toEqual ( jasmine . objectContaining ( { x : 0 , y : 1 , width : 1 , height : 1 , _dirty : true } ) ) ;
262
262
} ) ;
263
263
264
- it ( 'should respect locked nodes' , function ( ) {
264
+ it ( 'should respect locked nodes' , function ( ) {
265
265
engine . nodes = [
266
266
{ x : 0 , y : 1 , width : 1 , height : 1 , _id : 1 , locked : true } ,
267
267
{ x : 0 , y : 5 , width : 1 , height : 1 , _id : 2 } ,
@@ -275,4 +275,37 @@ describe('gridstack engine', function() {
275
275
} ) ;
276
276
} ) ;
277
277
} ) ;
278
+
279
+ describe ( 'test isNodeChangedPosition' , function ( ) {
280
+ var engine ;
281
+
282
+ beforeAll ( function ( ) {
283
+ engine = new GridStackUI . Engine ( 12 ) ;
284
+ } ) ;
285
+
286
+ it ( 'should return true for changed x' , function ( ) {
287
+ var widget = { x : 1 , y : 2 , width : 3 , height : 4 } ;
288
+ expect ( engine . isNodeChangedPosition ( widget , 2 , 2 ) ) . toEqual ( true ) ;
289
+ } ) ;
290
+
291
+ it ( 'should return true for changed y' , function ( ) {
292
+ var widget = { x : 1 , y : 2 , width : 3 , height : 4 } ;
293
+ expect ( engine . isNodeChangedPosition ( widget , 1 , 1 ) ) . toEqual ( true ) ;
294
+ } ) ;
295
+
296
+ it ( 'should return true for changed width' , function ( ) {
297
+ var widget = { x : 1 , y : 2 , width : 3 , height : 4 } ;
298
+ expect ( engine . isNodeChangedPosition ( widget , 2 , 2 , 4 , 4 ) ) . toEqual ( true ) ;
299
+ } ) ;
300
+
301
+ it ( 'should return true for changed height' , function ( ) {
302
+ var widget = { x : 1 , y : 2 , width : 3 , height : 4 } ;
303
+ expect ( engine . isNodeChangedPosition ( widget , 1 , 2 , 3 , 3 ) ) . toEqual ( true ) ;
304
+ } ) ;
305
+
306
+ it ( 'should return false for unchanged position' , function ( ) {
307
+ var widget = { x : 1 , y : 2 , width : 3 , height : 4 } ;
308
+ expect ( engine . isNodeChangedPosition ( widget , 1 , 2 , 3 , 4 ) ) . toEqual ( false ) ;
309
+ } ) ;
310
+ } ) ;
278
311
} ) ;
0 commit comments