Merge remote-tracking branch 'github/master' into open1515

This commit is contained in:
Victor Woeltjen
2015-09-24 11:17:13 -07:00
168 changed files with 14612 additions and 6722 deletions

View File

@@ -19,7 +19,7 @@
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/
/*global define,describe,it,expect,beforeEach,jasmine*/
define(
["../../src/controllers/TreeNodeController"],
@@ -29,6 +29,7 @@ define(
describe("The tree node controller", function () {
var mockScope,
mockTimeout,
mockDomainObject,
controller;
function TestObject(id, context) {
@@ -41,8 +42,13 @@ define(
}
beforeEach(function () {
mockScope = jasmine.createSpyObj("$scope", ["$watch", "$on"]);
mockScope = jasmine.createSpyObj("$scope", ["$watch", "$on", "$emit"]);
mockTimeout = jasmine.createSpy("$timeout");
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getCapability", "getModel", "useCapability" ]
);
controller = new TreeNodeController(mockScope, mockTimeout);
});
@@ -183,6 +189,22 @@ define(
expect(controller.isSelected()).toBeFalsy();
});
it("exposes selected objects in scope", function () {
mockScope.domainObject = mockDomainObject;
mockScope.ngModel = {};
controller.select();
expect(mockScope.ngModel.selectedObject)
.toEqual(mockDomainObject);
});
it("invokes optional callbacks upon selection", function () {
mockScope.parameters =
{ callback: jasmine.createSpy('callback') };
controller.select();
expect(mockScope.parameters.callback).toHaveBeenCalled();
});
});
}
);
);

View File

@@ -35,7 +35,7 @@ define(
beforeEach(function () {
mockTimeout = jasmine.createSpy("$timeout");
mockScope = jasmine.createSpyObj("$scope", ["$eval", "$on"]);
mockScope = jasmine.createSpyObj("$scope", ["$eval", "$on", "$apply"]);
testElement = { offsetWidth: 100, offsetHeight: 200 };
testAttrs = { mctResize: "some-expr" };
@@ -52,7 +52,8 @@ define(
mctResize.link(mockScope, [testElement], testAttrs);
expect(mockTimeout).toHaveBeenCalledWith(
jasmine.any(Function),
jasmine.any(Number)
jasmine.any(Number),
false
);
expect(mockScope.$eval).toHaveBeenCalledWith(
testAttrs.mctResize,
@@ -110,6 +111,35 @@ define(
expect(mockTimeout.calls.length).toEqual(2);
});
it("triggers a digest cycle when size changes", function () {
var applyCount;
mctResize.link(mockScope, [testElement], testAttrs);
applyCount = mockScope.$apply.calls.length;
// Change the element's apparent size
testElement.offsetWidth = 300;
testElement.offsetHeight = 350;
// Fire the timeout
mockTimeout.mostRecentCall.args[0]();
// No more apply calls
expect(mockScope.$apply.calls.length)
.toBeGreaterThan(applyCount);
});
it("does not trigger a digest cycle when size does not change", function () {
var applyCount;
mctResize.link(mockScope, [testElement], testAttrs);
applyCount = mockScope.$apply.calls.length;
// Fire the timeout
mockTimeout.mostRecentCall.args[0]();
// No more apply calls
expect(mockScope.$apply.calls.length).toEqual(applyCount);
});
});
}
);
);

View File

@@ -91,7 +91,7 @@ define(
it("get url for a new tab using domainObject and mode", function () {
urlService.urlForNewTab(mockMode, mockDomainObject);
});
});
});
}
);