[Fixed Position] Add unit tests
This commit is contained in:
@@ -24,6 +24,8 @@ define(
|
||||
['../../src/elements/ElementProxy'],
|
||||
function (ElementProxy) {
|
||||
|
||||
var GRID_SIZE = [13,21];
|
||||
|
||||
describe("A fixed position element proxy", function () {
|
||||
var testElement,
|
||||
testElements,
|
||||
@@ -35,13 +37,15 @@ define(
|
||||
y: 2,
|
||||
stroke: '#717171',
|
||||
width: 42,
|
||||
height: 24
|
||||
height: 24,
|
||||
useGrid: true
|
||||
};
|
||||
testElements = [{}, {}, testElement, {}];
|
||||
proxy = new ElementProxy(
|
||||
testElement,
|
||||
testElements.indexOf(testElement),
|
||||
testElements
|
||||
testElements,
|
||||
GRID_SIZE
|
||||
);
|
||||
});
|
||||
|
||||
@@ -73,6 +77,29 @@ define(
|
||||
expect(proxy.x()).toEqual(0);
|
||||
expect(proxy.y()).toEqual(0);
|
||||
});
|
||||
|
||||
it("allows modifying the current grid size", function () {
|
||||
proxy.setGridSize([112,420]);
|
||||
expect(proxy.gridSize).toEqual([112,420]);
|
||||
});
|
||||
|
||||
it("returns the current grid size only if the element snaps to grid", function () {
|
||||
expect(proxy.getGridSize()).toEqual([13,21]);
|
||||
proxy.useGrid(false);
|
||||
expect(proxy.getGridSize()).toEqual([1,1]);
|
||||
});
|
||||
|
||||
it("returns the mininum height and width of an element currently used units", function () {
|
||||
// Assumes mininum height and width are 10, in pixels
|
||||
expect(proxy.getMinWidth()).toEqual(1);
|
||||
expect(proxy.getMinHeight()).toEqual(1);
|
||||
proxy.setGridSize([7,4]);
|
||||
expect(proxy.getMinWidth()).toEqual(2);
|
||||
expect(proxy.getMinHeight()).toEqual(3);
|
||||
proxy.useGrid(false);
|
||||
expect(proxy.getMinWidth()).toEqual(10);
|
||||
expect(proxy.getMinHeight()).toEqual(10);
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user