[Fixed Controller] Add test cases

Add test cases for updating position of elements in
a fixed position view, WTD-1344.
This commit is contained in:
Victor Woeltjen
2015-06-25 10:58:01 -07:00
parent 4279c9e4bf
commit 9e55befb2a

View File

@@ -137,11 +137,6 @@ define(
); );
}); });
it("provides styles for cells", function () {
expect(controller.getCellStyles())
.toEqual(jasmine.any(Array));
});
it("subscribes when a domain object is available", function () { it("subscribes when a domain object is available", function () {
mockScope.domainObject = mockDomainObject; mockScope.domainObject = mockDomainObject;
findWatch("domainObject")(mockDomainObject); findWatch("domainObject")(mockDomainObject);
@@ -266,25 +261,19 @@ define(
expect(elements[2].value).toEqual("Formatted 31.42"); expect(elements[2].value).toEqual("Formatted 31.42");
}); });
it("adds grid cells to fill boundaries", function () { it("updates elements styles when grid size changes", function () {
var s1 = { var originalLeft;
width: testGrid[0] * 8,
height: testGrid[1] * 4
},
s2 = {
width: testGrid[0] * 10,
height: testGrid[1] * 6
};
mockScope.domainObject = mockDomainObject;
mockScope.model = testModel; mockScope.model = testModel;
findWatch("domainObject")(mockDomainObject);
findWatch("model.modified")(1);
findWatch("model.composition")(mockScope.model.composition); findWatch("model.composition")(mockScope.model.composition);
findWatch("model.layoutGrid")([10, 10]);
// Set first bounds originalLeft = controller.getElements()[0].style.left;
controller.setBounds(s1); findWatch("model.layoutGrid")([20, 20]);
expect(controller.getCellStyles().length).toEqual(32); // 8 * 4 expect(controller.getElements()[0].style.left)
// Set new bounds .not.toEqual(originalLeft);
controller.setBounds(s2);
expect(controller.getCellStyles().length).toEqual(60); // 10 * 6
}); });
it("listens for drop events", function () { it("listens for drop events", function () {
@@ -328,6 +317,7 @@ define(
}); });
it("exposes its grid size", function () { it("exposes its grid size", function () {
findWatch('model.layoutGrid')(testGrid);
// Template needs to be able to pass this into line // Template needs to be able to pass this into line
// elements to size SVGs appropriately // elements to size SVGs appropriately
expect(controller.getGridSize()).toEqual(testGrid); expect(controller.getGridSize()).toEqual(testGrid);