';
let el = doc.body.children[0] as HTMLElement;
grid.el.appendChild(el);
- let widget = grid.makeWidget(el);
- expect(parseInt(widget.getAttribute('gs-x'), 10)).toBe(0);
+ let w = grid.makeWidget(el);
+ expect(parseInt(w.getAttribute('gs-x'), 10)).toBe(0);
});
- it('passing element float=true', function() {
- let grid = GridStack.init({float: true});
+ it('passing element float=true >', function() {
+ grid = GridStack.init({float: true});
let doc = document.implementation.createHTMLDocument();
doc.body.innerHTML = '
';
let el = doc.body.children[0] as HTMLElement;
grid.el.appendChild(el);
- let widget = grid.makeWidget(el);
- expect(parseInt(widget.getAttribute('gs-x'), 10)).toBe(0);
+ let w = grid.makeWidget(el);
+ expect(parseInt(w.getAttribute('gs-x'), 10)).toBe(0);
});
- it('passing class', function() {
- let grid = GridStack.init();
+ it('passing class >', function() {
+ grid = GridStack.init();
let doc = document.implementation.createHTMLDocument();
doc.body.innerHTML = '
';
let el = doc.body.children[0] as HTMLElement;
grid.el.appendChild(el);
- let widget = grid.makeWidget('.item');
- expect(parseInt(widget.getAttribute('gs-x'), 10)).toBe(0);
+ let w = grid.makeWidget('.item');
+ expect(parseInt(w.getAttribute('gs-x'), 10)).toBe(0);
});
- it('passing class no dot', function() {
- let grid = GridStack.init();
+ it('passing class no dot >', function() {
+ grid = GridStack.init();
let doc = document.implementation.createHTMLDocument();
doc.body.innerHTML = '
';
let el = doc.body.children[0] as HTMLElement;
grid.el.appendChild(el);
- let widget = grid.makeWidget('item');
- expect(parseInt(widget.getAttribute('gs-x'), 10)).toBe(0);
+ let w = grid.makeWidget('item');
+ expect(parseInt(w.getAttribute('gs-x'), 10)).toBe(0);
});
- it('passing id', function() {
- let grid = GridStack.init();
+ it('passing id >', function() {
+ grid = GridStack.init();
let doc = document.implementation.createHTMLDocument();
doc.body.innerHTML = '
';
let el = doc.body.children[0] as HTMLElement;
grid.el.appendChild(el);
- let widget = grid.makeWidget('#item');
- expect(parseInt(widget.getAttribute('gs-x'), 10)).toBe(0);
+ let w = grid.makeWidget('#item');
+ expect(parseInt(w.getAttribute('gs-x'), 10)).toBe(0);
});
- it('passing id no #', function() {
- let grid = GridStack.init();
+ it('passing id no # >', function() {
+ grid = GridStack.init();
let doc = document.implementation.createHTMLDocument();
doc.body.innerHTML = '
';
let el = doc.body.children[0] as HTMLElement;
grid.el.appendChild(el);
- let widget = grid.makeWidget('item');
- expect(parseInt(widget.getAttribute('gs-x'), 10)).toBe(0);
+ let w = grid.makeWidget('item');
+ expect(parseInt(w.getAttribute('gs-x'), 10)).toBe(0);
});
- it('passing id as number', function() {
- let grid = GridStack.init();
+ it('passing id as number >', function() {
+ grid = GridStack.init();
let doc = document.implementation.createHTMLDocument();
doc.body.innerHTML = '
';
let el = doc.body.children[0] as HTMLElement;
grid.el.appendChild(el);
- let widget = grid.makeWidget('1');
- expect(parseInt(widget.getAttribute('gs-x'), 10)).toBe(0);
+ let w = grid.makeWidget('1');
+ expect(parseInt(w.getAttribute('gs-x'), 10)).toBe(0);
});
});
- describe('method getFloat()', function() {
+ describe('method getFloat() >', function() {
beforeEach(function() {
document.body.insertAdjacentHTML('afterbegin', gridstackHTML);
});
afterEach(function() {
document.body.removeChild(document.getElementById('gs-cont'));
});
- it('should match true/false only', function() {
- let grid = GridStack.init({float: true});
+ it('should match true/false only >', function() {
+ grid = GridStack.init({float: true});
expect(grid.getFloat()).toBe(true);
(grid as any).float(0);
expect(grid.getFloat()).toBe(false);
@@ -1044,31 +1044,31 @@ describe('gridstack', function() {
});
});
- describe('grid.destroy', function() {
+ describe('grid.destroy >', function() {
beforeEach(function() {
document.body.insertAdjacentHTML('afterbegin', gridstackHTML);
});
afterEach(function() {
document.getElementById('gs-cont').remove();
});
- it('should cleanup gridstack', function() {
+ it('should cleanup gridstack >', function() {
let options = {
cellHeight: 80,
margin: 5
};
- let grid = GridStack.init(options);
+ grid = GridStack.init(options);
let gridEl = grid.el;
grid.destroy();
expect(gridEl.parentElement).toBe(null);
expect(grid.el).toBe(undefined);
expect(grid.engine).toBe(undefined);
});
- it('should cleanup gridstack but leave elements', function() {
+ it('should cleanup gridstack but leave elements >', function() {
let options = {
cellHeight: 80,
margin: 5
};
- let grid = GridStack.init(options);
+ grid = GridStack.init(options);
let gridEl = grid.el;
grid.destroy(false);
expect(gridEl.parentElement).not.toBe(null);
@@ -1079,19 +1079,19 @@ describe('gridstack', function() {
});
});
- describe('grid.resize', function() {
+ describe('grid.resize >', function() {
beforeEach(function() {
document.body.insertAdjacentHTML('afterbegin', gridstackHTML);
});
afterEach(function() {
document.body.removeChild(document.getElementById('gs-cont'));
});
- it('should resize widget', function() {
+ it('should resize widget >', function() {
let options = {
cellHeight: 80,
margin: 5
};
- let grid = GridStack.init(options);
+ grid = GridStack.init(options);
let items = Utils.getElements('.grid-stack-item');
grid.update(items[0], {w:5, h:5});
expect(parseInt(items[0].getAttribute('gs-w'), 10)).toBe(5);
@@ -1099,20 +1099,20 @@ describe('gridstack', function() {
});
});
- describe('grid.move', function() {
+ describe('grid.move >', function() {
beforeEach(function() {
document.body.insertAdjacentHTML('afterbegin', gridstackHTML);
});
afterEach(function() {
document.body.removeChild(document.getElementById('gs-cont'));
});
- it('should move widget', function() {
+ it('should move widget >', function() {
let options = {
cellHeight: 80,
margin: 5,
float: true
};
- let grid = GridStack.init(options);
+ grid = GridStack.init(options);
let items = Utils.getElements('.grid-stack-item');
grid.update(items[0], {x:5, y:5});
expect(parseInt(items[0].getAttribute('gs-x'), 10)).toBe(5);
@@ -1120,15 +1120,15 @@ describe('gridstack', function() {
});
});
- describe('grid.update', function() {
+ describe('grid.update >', function() {
beforeEach(function() {
document.body.insertAdjacentHTML('afterbegin', gridstackHTML);
});
afterEach(function() {
document.body.removeChild(document.getElementById('gs-cont'));
});
- it('should move and resize widget', function() {
- let grid = GridStack.init({float: true});
+ it('should move and resize widget >', function() {
+ grid = GridStack.init({float: true});
let el = Utils.getElements('.grid-stack-item')[1];
expect(parseInt(el.getAttribute('gs-w'), 10)).toBe(4);
@@ -1138,8 +1138,8 @@ describe('gridstack', function() {
expect(parseInt(el.getAttribute('gs-w'), 10)).toBe(4);
expect(parseInt(el.getAttribute('gs-h'), 10)).toBe(2);
});
- it('should change noMove', function() {
- let grid = GridStack.init({float: true});
+ it('should change noMove >', function() {
+ grid = GridStack.init({float: true});
let items = Utils.getElements('.grid-stack-item');
let el = items[1];
let dd = GridStack.getDD();
@@ -1157,13 +1157,13 @@ describe('gridstack', function() {
expect(parseInt(el.getAttribute('gs-w'), 10)).toBe(4);
expect(parseInt(el.getAttribute('gs-h'), 10)).toBe(4);
});
- it('should change content and id, and move', function() {
- let grid = GridStack.init({float: true});
- let items = Utils.getElements('.grid-stack-item');
- let el = items[1];
+ it('should change content and id, and move >', function() {
+ grid = GridStack.init({float: true});
+ let el = findEl('gsItem2');
let sub = el.querySelector('.grid-stack-item-content');
grid.update(el, {id: 'newID', y: 1, content: 'new content'});
+ expect(el.gridstackNode.id).toBe('newID');
expect(el.getAttribute('gs-id')).toBe('newID');
expect(sub.innerHTML).toBe('new content');
expect(parseInt(el.getAttribute('gs-x'), 10)).toBe(4);
@@ -1171,10 +1171,9 @@ describe('gridstack', function() {
expect(parseInt(el.getAttribute('gs-w'), 10)).toBe(4);
expect(parseInt(el.getAttribute('gs-h'), 10)).toBe(4);
});
- it('should change max and constrain a wanted resize', function() {
- let grid = GridStack.init({float: true});
- let items = Utils.getElements('.grid-stack-item');
- let el: GridItemHTMLElement = items[1];
+ it('should change max and constrain a wanted resize >', function() {
+ grid = GridStack.init({float: true});
+ let el = findEl('gsItem2');
expect(el.getAttribute('gs-max-w')).toBe(null);
grid.update(el, {maxW: 2, w: 5});
@@ -1184,10 +1183,9 @@ describe('gridstack', function() {
expect(parseInt(el.getAttribute('gs-h'), 10)).toBe(4);
expect(el.gridstackNode.maxW).toBe(2);
});
- it('should change max and constrain existing', function() {
- let grid = GridStack.init({float: true});
- let items = Utils.getElements('.grid-stack-item');
- let el: GridItemHTMLElement = items[1];
+ it('should change max and constrain existing >', function() {
+ grid = GridStack.init({float: true});
+ let el = findEl('gsItem2');
expect(el.getAttribute('gs-max-w')).toBe(null);
grid.update(el, {maxW: 2});
@@ -1197,8 +1195,8 @@ describe('gridstack', function() {
expect(el.gridstackNode.maxW).toBe(2);
expect(parseInt(el.getAttribute('gs-w'), 10)).toBe(2);
});
- it('should change all max and move', function() {
- let grid = GridStack.init({float: true});
+ it('should change all max and move, no inf loop! >', function() {
+ grid = GridStack.init({float: true});
let items = Utils.getElements('.grid-stack-item');
items.forEach(item => {
@@ -1217,44 +1215,43 @@ describe('gridstack', function() {
expect(item.gridstackNode.maxH).toBe(2);
});
});
-
});
- describe('grid.margin', function() {
+ describe('grid.margin >', function() {
beforeEach(function() {
document.body.insertAdjacentHTML('afterbegin', gridstackHTML);
});
afterEach(function() {
document.body.removeChild(document.getElementById('gs-cont'));
});
- it('should return margin', function() {
+ it('should return margin >', function() {
let options = {
cellHeight: 80,
margin: 12
};
- let grid = GridStack.init(options);
+ grid = GridStack.init(options);
expect(grid.getMargin()).toBe(12);
});
- it('should return update margin', function() {
+ it('should return update margin >', function() {
let options = {
cellHeight: 80,
margin: 5
};
- let grid = GridStack.init(options);
+ grid = GridStack.init(options);
grid.margin('11rem');
expect(grid.getMargin()).toBe(11);
});
- it('should change unit', function() {
+ it('should change unit >', function() {
let options = {
cellHeight: 80,
margin: 10,
};
- let grid = GridStack.init(options);
+ grid = GridStack.init(options);
expect(grid.getMargin()).toBe(10);
grid.margin('10rem');
expect(grid.getMargin()).toBe(10);
});
- it('should not update styles, with same value', function() {
+ it('should not update styles, with same value >', function() {
let options = {
cellHeight: 80,
margin: 5
@@ -1266,7 +1263,7 @@ describe('gridstack', function() {
expect(grid._updateStyles).not.toHaveBeenCalled();
expect(grid.getMargin()).toBe(5);
});
- it('should set top/bot/left value directly', function() {
+ it('should set top/bot/left value directly >', function() {
let options = {
cellHeight: 80,
marginTop: 5,
@@ -1280,7 +1277,7 @@ describe('gridstack', function() {
expect(grid.opts.marginLeft).toBe(1);
expect(grid.opts.marginRight).toBe(10); // default value
});
- it('should set all 4 sides, and overall margin', function() {
+ it('should set all 4 sides, and overall margin >', function() {
let options = {
cellHeight: 80,
marginTop: 5,
@@ -1295,7 +1292,7 @@ describe('gridstack', function() {
expect(grid.opts.marginLeft).toBe(5);
expect(grid.opts.marginRight).toBe(5);
});
- it('init 2 values', function() {
+ it('init 2 values >', function() {
let options = {
cellHeight: 80,
margin: '5px 10'
@@ -1307,7 +1304,7 @@ describe('gridstack', function() {
expect(grid.opts.marginLeft).toBe(10);
expect(grid.opts.marginRight).toBe(10);
});
- it('init 4 values', function() {
+ it('init 4 values >', function() {
let options = {
cellHeight: 80,
margin: '1 2 0em 3'
@@ -1319,12 +1316,12 @@ describe('gridstack', function() {
expect(grid.opts.marginBottom).toBe(0);
expect(grid.opts.marginLeft).toBe(3);
});
- it('set 2 values, should update style', function() {
+ it('set 2 values, should update style >', function() {
let options = {
cellHeight: 80,
margin: 5
};
- let grid = GridStack.init(options);
+ grid = GridStack.init(options);
expect(grid.getMargin()).toBe(5);
spyOn(grid as any, '_updateStyles');
grid.margin('1px 0');
@@ -1337,40 +1334,40 @@ describe('gridstack', function() {
});
});
- describe('grid.opts.rtl', function() {
+ describe('grid.opts.rtl >', function() {
beforeEach(function() {
document.body.insertAdjacentHTML('afterbegin', gridstackHTML);
});
afterEach(function() {
document.body.removeChild(document.getElementById('gs-cont'));
});
- it('should add grid-stack-rtl class', function() {
+ it('should add grid-stack-rtl class >', function() {
let options = {
cellHeight: 80,
margin: 5,
rtl: true
};
- let grid = GridStack.init(options);
+ grid = GridStack.init(options);
expect(grid.el.classList.contains('grid-stack-rtl')).toBe(true);
});
- it('should not add grid-stack-rtl class', function() {
+ it('should not add grid-stack-rtl class >', function() {
let options = {
cellHeight: 80,
margin: 5
};
- let grid = GridStack.init(options);
+ grid = GridStack.init(options);
expect(grid.el.classList.contains('grid-stack-rtl')).toBe(false);
});
});
- describe('grid.opts.styleInHead', function() {
+ describe('grid.opts.styleInHead >', function() {
beforeEach(function() {
document.body.insertAdjacentHTML('afterbegin', gridstackHTML);
});
afterEach(function() {
document.body.removeChild(document.getElementById('gs-cont'));
});
- it('should add STYLE to parent node as a default', function() {
+ it('should add STYLE to parent node as a default >', function() {
var options = {
cellHeight: 80,
verticalMargin: 10,
@@ -1379,7 +1376,7 @@ describe('gridstack', function() {
var grid = GridStack.init(options);
expect((grid as any)._styles.ownerNode.parentNode.tagName).toBe('DIV'); // any to access private _styles
});
- it('should add STYLE to HEAD if styleInHead === true', function() {
+ it('should add STYLE to HEAD if styleInHead === true >', function() {
var options = {
cellHeight: 80,
verticalMargin: 10,
@@ -1391,175 +1388,164 @@ describe('gridstack', function() {
});
});
- describe('grid.opts.styleInHead', function() {
+ describe('grid.opts.styleInHead >', function() {
beforeEach(function() {
document.body.insertAdjacentHTML('afterbegin', gridstackHTML);
});
afterEach(function() {
document.body.removeChild(document.getElementById('gs-cont'));
});
- it('should add STYLE to parent node as a default', function() {
+ it('should add STYLE to parent node as a default >', function() {
var grid = GridStack.init();
expect((grid as any)._styles.ownerNode.parentNode.tagName).toBe('DIV');
});
- it('should add STYLE to HEAD if styleInHead === true', function() {
+ it('should add STYLE to HEAD if styleInHead === true >', function() {
var grid = GridStack.init({styleInHead: true});
expect((grid as any)._styles.ownerNode.parentNode.tagName).toBe('HEAD');
});
});
- describe('grid.enableMove', function() {
+ describe('grid.enableMove >', function() {
beforeEach(function() {
document.body.insertAdjacentHTML('afterbegin', gridstackHTML);
});
afterEach(function() {
document.body.removeChild(document.getElementById('gs-cont'));
});
- it('should enable move for future also', function() {
+ it('should enable move for future also >', function() {
let options = {
cellHeight: 80,
margin: 5,
disableDrag: true
};
- let grid = GridStack.init(options);
+ grid = GridStack.init(options);
let items = Utils.getElements('.grid-stack-item');
- for (let i = 0; i < items.length; i++) {
- expect(items[i].classList.contains('ui-draggable-disabled')).toBe(true);
- }
+ items.forEach(el => expect(el.classList.contains('ui-draggable-disabled')).toBe(true));
expect(grid.opts.disableDrag).toBe(true);
grid.enableMove(true);
- for (let i = 0; i < items.length; i++) {
- expect(items[i].classList.contains('ui-draggable-disabled')).toBe(false);
- }
- expect(grid.opts.disableDrag).toBe(false);
+ items.forEach(el => expect(el.classList.contains('ui-draggable-disabled')).toBe(false));
+ expect(grid.opts.disableDrag).not.toBe(true);
});
- it('should disable move for existing only', function() {
+ it('should disable move for existing only >', function() {
let options = {
cellHeight: 80,
margin: 5
};
- let grid = GridStack.init(options);
+ grid = GridStack.init(options);
let items = Utils.getElements('.grid-stack-item');
- for (let i = 0; i < items.length; i++) {
- expect(items[i].classList.contains('ui-draggable-disabled')).toBe(false);
- }
+ items.forEach(el => expect(el.classList.contains('ui-draggable-disabled')).toBe(false));
expect(grid.opts.disableDrag).toBeFalsy();
grid.enableMove(false);
- for (let i = 0; i < items.length; i++) {
- expect(items[i].classList.contains('ui-draggable-disabled')).toBe(true);
- }
+ items.forEach(el => expect(el.classList.contains('ui-draggable-disabled')).toBe(true));
expect(grid.opts.disableDrag).toBe(true);
});
});
- describe('grid.enableResize', function() {
+ describe('grid.enableResize >', function() {
beforeEach(function() {
document.body.insertAdjacentHTML('afterbegin', gridstackHTML);
});
afterEach(function() {
document.body.removeChild(document.getElementById('gs-cont'));
});
- it('should enable resize', function() {
+ it('should enable resize >', function() {
let options = {
cellHeight: 80,
margin: 5,
disableResize: true
};
- let grid = GridStack.init(options);
+ grid = GridStack.init(options);
expect(grid.opts.disableResize).toBe(true);
let items = Utils.getElements('.grid-stack-item');
let dd = GridStack.getDD();
- // expect(dd).toBe(null); // sanity test to verify type
- for (let i = 0; i < items.length; i++) {
- expect(dd.isResizable(items[i])).toBe(false);
- expect(dd.isDraggable(items[i])).toBe(true);
- }
+ expect(dd).not.toBe(null); // sanity test to verify type
+ items.forEach(el => {
+ expect(dd.isResizable(el)).toBe(false);
+ expect(dd.isDraggable(el)).toBe(true);
+ });
grid.enableResize(true);
- expect(grid.opts.disableResize).toBe(false);
- for (let i = 0; i < items.length; i++) {
- expect(dd.isResizable(items[i])).toBe(true);
- expect(dd.isDraggable(items[i])).toBe(true);
- }
+ expect(grid.opts.disableResize).not.toBe(true);
+ items.forEach(el => {
+ expect(dd.isResizable(el)).toBe(true);
+ expect(dd.isDraggable(el)).toBe(true);
+ });
});
- it('should disable resize', function() {
+ it('should disable resize >', function() {
let options = {
cellHeight: 80,
margin: 5
};
- let grid = GridStack.init(options);
+ grid = GridStack.init(options);
expect(grid.opts.disableResize).toBeFalsy();
let items = Utils.getElements('.grid-stack-item');
let dd = GridStack.getDD();
- for (let i = 0; i < items.length; i++) {
- expect(dd.isResizable(items[i])).toBe(true);
- expect(dd.isDraggable(items[i])).toBe(true);
- }
+ items.forEach(el => expect(dd.isResizable(el)).toBe(true));
grid.enableResize(false);
expect(grid.opts.disableResize).toBe(true);
- for (let i = 0; i < items.length; i++) {
- expect(dd.isResizable(items[i])).toBe(false);
- expect(dd.isDraggable(items[i])).toBe(true);
- }
+ items.forEach(el => {
+ expect(dd.isResizable(el)).toBe(false);
+ expect(dd.isDraggable(el)).toBe(true);
+ });
});
});
- describe('grid.enable', function() {
+ describe('grid.enable >', function() {
beforeEach(function() {
document.body.insertAdjacentHTML('afterbegin', gridstackHTML);
});
afterEach(function() {
document.body.removeChild(document.getElementById('gs-cont'));
});
- it('should enable movable and resizable', function() {
+ it('should enable movable and resizable >', function() {
let options = {
cellHeight: 80,
margin: 5
};
- let grid = GridStack.init(options);
+ grid = GridStack.init(options);
let items = Utils.getElements('.grid-stack-item');
let dd = GridStack.getDD();
grid.enableResize(false);
grid.enableMove(false);
- for (let i = 0; i < items.length; i++) {
- expect(items[i].classList.contains('ui-draggable-disabled')).toBe(true);
- expect(dd.isResizable(items[i])).toBe(false);
- expect(dd.isDraggable(items[i])).toBe(false);
- }
+ items.forEach(el => {
+ expect(el.classList.contains('ui-draggable-disabled')).toBe(true);
+ expect(dd.isResizable(el)).toBe(false);
+ expect(dd.isDraggable(el)).toBe(false);
+ });
grid.enable();
- for (let j = 0; j < items.length; j++) {
- expect(items[j].classList.contains('ui-draggable-disabled')).toBe(false);
- expect(dd.isResizable(items[j])).toBe(true);
- expect(dd.isDraggable(items[j])).toBe(true);
- }
+ items.forEach(el => {
+ expect(el.classList.contains('ui-draggable-disabled')).toBe(false);
+ expect(dd.isResizable(el)).toBe(true);
+ expect(dd.isDraggable(el)).toBe(true);
+ });
});
});
- describe('grid.enable', function() {
+ describe('grid.enable >', function() {
beforeEach(function() {
document.body.insertAdjacentHTML('afterbegin', gridstackHTML);
});
afterEach(function() {
document.body.removeChild(document.getElementById('gs-cont'));
});
- it('should lock widgets', function() {
+ it('should lock widgets >', function() {
let options = {
cellHeight: 80,
margin: 5
};
- let grid = GridStack.init(options);
+ grid = GridStack.init(options);
grid.update('.grid-stack-item', {locked: true});
Utils.getElements('.grid-stack-item').forEach(item => {
expect(item.getAttribute('gs-locked')).toBe('true');
})
});
- it('should unlock widgets', function() {
+ it('should unlock widgets >', function() {
let options = {
cellHeight: 80,
margin: 5
};
- let grid = GridStack.init(options);
+ grid = GridStack.init(options);
grid.update('.grid-stack-item', {locked: false});
Utils.getElements('.grid-stack-item').forEach(item => {
expect(item.getAttribute('gs-locked')).toBe(null);
@@ -1567,7 +1553,7 @@ describe('gridstack', function() {
});
});
- describe('custom grid placement #1054', function() {
+ describe('custom grid placement #1054 >', function() {
let HTML =
'