@@ -14,7 +14,7 @@ describe('gridstack engine', function() {
1414
1515 beforeAll ( function ( ) {
1616 engine = new GridStackUI . Engine ( 12 ) ;
17- } )
17+ } ) ;
1818
1919 it ( 'should be setup properly' , function ( ) {
2020 expect ( engine . width ) . toEqual ( 12 ) ;
@@ -29,7 +29,7 @@ describe('gridstack engine', function() {
2929
3030 beforeAll ( function ( ) {
3131 engine = new GridStackUI . Engine ( 12 ) ;
32- } )
32+ } ) ;
3333
3434 it ( 'should prepare a node' , function ( ) {
3535 expect ( engine . _prepareNode ( { } , false ) ) . toEqual ( jasmine . objectContaining ( { x : 0 , y : 0 , width : 1 , height : 1 } ) ) ;
@@ -57,7 +57,7 @@ describe('gridstack engine', function() {
5757 engine . nodes = [
5858 engine . _prepareNode ( { x : 3 , y : 2 , width : 3 , height : 2 } )
5959 ] ;
60- } )
60+ } ) ;
6161
6262 it ( 'should be true' , function ( ) {
6363 expect ( engine . isAreaEmpty ( 0 , 0 , 3 , 2 ) ) . toEqual ( true ) ;
@@ -108,14 +108,14 @@ describe('gridstack engine', function() {
108108 } ) ;
109109 } ) ;
110110
111- describe ( 'test batchUpdate/commit' , function ( ) {
111+ describe ( 'test batchUpdate/commit' , function ( ) {
112112 var engine ;
113113
114- beforeAll ( function ( ) {
115- engine = new GridStackUI . Engine ( 12 )
114+ beforeAll ( function ( ) {
115+ engine = new GridStackUI . Engine ( 12 ) ;
116116 } ) ;
117117
118- it ( 'should work on not float grids' , function ( ) {
118+ it ( 'should work on not float grids' , function ( ) {
119119 expect ( engine . float ) . toEqual ( false ) ;
120120 engine . batchUpdate ( ) ;
121121 expect ( engine . _updateCounter ) . toBeGreaterThan ( 0 ) ;
@@ -126,14 +126,14 @@ describe('gridstack engine', function() {
126126 } ) ;
127127 } ) ;
128128
129- describe ( 'test batchUpdate/commit' , function ( ) {
129+ describe ( 'test batchUpdate/commit' , function ( ) {
130130 var engine ;
131131
132- beforeAll ( function ( ) {
133- engine = new GridStackUI . Engine ( 12 , null , true )
132+ beforeAll ( function ( ) {
133+ engine = new GridStackUI . Engine ( 12 , null , true ) ;
134134 } ) ;
135135
136- it ( 'should work on float grids' , function ( ) {
136+ it ( 'should work on float grids' , function ( ) {
137137 expect ( engine . float ) . toEqual ( true ) ;
138138 engine . batchUpdate ( ) ;
139139 expect ( engine . _updateCounter ) . toBeGreaterThan ( 0 ) ;
@@ -150,8 +150,8 @@ describe('gridstack engine', function() {
150150
151151 beforeEach ( function ( ) {
152152 spy = {
153- callback : function ( ) { }
154- }
153+ callback : function ( ) { }
154+ } ;
155155 spyOn ( spy , 'callback' ) ;
156156
157157 engine = new GridStackUI . Engine ( 12 , spy . callback , true ) ;
@@ -204,19 +204,19 @@ describe('gridstack engine', function() {
204204 } ) ;
205205 } ) ;
206206
207- describe ( 'test _packNodes' , function ( ) {
208- describe ( 'using not float mode' , function ( ) {
207+ describe ( 'test _packNodes' , function ( ) {
208+ describe ( 'using not float mode' , function ( ) {
209209 var engine ;
210210
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+ } ;
214214
215- beforeEach ( function ( ) {
215+ beforeEach ( function ( ) {
216216 engine = new GridStackUI . Engine ( 12 , null , false ) ;
217217 } ) ;
218218
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 ( ) {
220220 engine . nodes = [
221221 { x : 0 , y : 0 , width : 1 , height : 1 , _id : 1 } ,
222222 ] ;
@@ -227,7 +227,7 @@ describe('gridstack engine', function() {
227227 expect ( findNode ( engine , 1 ) . _dirty ) . toBeFalsy ( ) ;
228228 } ) ;
229229
230- it ( 'should pack one node correctly' , function ( ) {
230+ it ( 'should pack one node correctly' , function ( ) {
231231 engine . nodes = [
232232 { x : 0 , y : 1 , width : 1 , height : 1 , _id : 1 } ,
233233 ] ;
@@ -237,7 +237,7 @@ describe('gridstack engine', function() {
237237 expect ( findNode ( engine , 1 ) ) . toEqual ( jasmine . objectContaining ( { x : 0 , y : 0 , width : 1 , height : 1 , _dirty : true } ) ) ;
238238 } ) ;
239239
240- it ( 'should pack nodes correctly' , function ( ) {
240+ it ( 'should pack nodes correctly' , function ( ) {
241241 engine . nodes = [
242242 { x : 0 , y : 1 , width : 1 , height : 1 , _id : 1 } ,
243243 { x : 0 , y : 5 , width : 1 , height : 1 , _id : 2 } ,
@@ -249,7 +249,7 @@ describe('gridstack engine', function() {
249249 expect ( findNode ( engine , 2 ) ) . toEqual ( jasmine . objectContaining ( { x : 0 , y : 1 , width : 1 , height : 1 , _dirty : true } ) ) ;
250250 } ) ;
251251
252- it ( 'should pack nodes correctly' , function ( ) {
252+ it ( 'should pack nodes correctly' , function ( ) {
253253 engine . nodes = [
254254 { x : 0 , y : 5 , width : 1 , height : 1 , _id : 1 } ,
255255 { x : 0 , y : 1 , width : 1 , height : 1 , _id : 2 } ,
@@ -261,7 +261,7 @@ describe('gridstack engine', function() {
261261 expect ( findNode ( engine , 1 ) ) . toEqual ( jasmine . objectContaining ( { x : 0 , y : 1 , width : 1 , height : 1 , _dirty : true } ) ) ;
262262 } ) ;
263263
264- it ( 'should respect locked nodes' , function ( ) {
264+ it ( 'should respect locked nodes' , function ( ) {
265265 engine . nodes = [
266266 { x : 0 , y : 1 , width : 1 , height : 1 , _id : 1 , locked : true } ,
267267 { x : 0 , y : 5 , width : 1 , height : 1 , _id : 2 } ,
@@ -275,4 +275,37 @@ describe('gridstack engine', function() {
275275 } ) ;
276276 } ) ;
277277 } ) ;
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+ } ) ;
278311} ) ;
0 commit comments