[Mobile] Tests

Adjusted TreeNodeControllerSpec to
test setObject prototype.
This commit is contained in:
Shivam Dave 2015-08-25 14:49:38 -07:00
parent 9cd57614e4
commit 0fa330adff

View File

@ -30,6 +30,8 @@ define(
var mockScope, var mockScope,
mockTimeout, mockTimeout,
mockAgentService, mockAgentService,
mockNgModel,
mockDomainObject,
controller; controller;
function TestObject(id, context) { function TestObject(id, context) {
@ -42,9 +44,18 @@ define(
} }
beforeEach(function () { beforeEach(function () {
mockScope = jasmine.createSpyObj("$scope", ["$watch", "$on"]); mockScope = jasmine.createSpyObj("$scope", ["$watch", "$on", "$emit"]);
mockTimeout = jasmine.createSpy("$timeout"); mockTimeout = jasmine.createSpy("$timeout");
mockAgentService = jasmine.createSpyObj("agentService", ["isMobile"]); mockAgentService = jasmine.createSpyObj("agentService", ["isMobile", "isPhone", "getOrientation"]);
mockNgModel = jasmine.createSpyObj("ngModel", ["selectedObject"]);
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getCapability", "getModel", "useCapability" ]
);
mockAgentService.getOrientation.andReturn("portrait");
mockAgentService.isPhone.andReturn(true);
controller = new TreeNodeController(mockScope, mockTimeout, mockAgentService); controller = new TreeNodeController(mockScope, mockTimeout, mockAgentService);
}); });
@ -191,6 +202,11 @@ define(
controller.checkMobile(); controller.checkMobile();
} }
}); });
it("allows a set object to emit select-obj", function () {
controller.setObject(mockNgModel, mockDomainObject);
expect(mockScope.$emit).toHaveBeenCalledWith('select-obj');
});
}); });
} }
); );