[Browse] Tests completed

Completed the menu arrow controller test. All
tests are now completed. #33.
This commit is contained in:
Sarah Hale 2015-07-07 09:28:01 -07:00
parent e3a96eff8d
commit b2a23ee968
2 changed files with 16 additions and 39 deletions

View File

@ -29,11 +29,7 @@ define(
function (MenuArrowController) { function (MenuArrowController) {
"use strict"; "use strict";
//var JQLITE_FUNCTIONS = [ "on", "off", "find", "append", "remove" ], describe("The menu arrow controller ", function () {
// DOMAIN_OBJECT_METHODS = [ "getId", "getModel", "getCapability", "hasCapability", "useCapability" ];
describe("The menu arrow controller", function () {
var mockScope, var mockScope,
mockDomainObject, mockDomainObject,
mockEvent, mockEvent,
@ -44,7 +40,7 @@ define(
beforeEach(function () { beforeEach(function () {
mockScope = jasmine.createSpyObj( mockScope = jasmine.createSpyObj(
"$scope", "$scope",
[ "$on", "$watch" ] [ "" ]
); );
mockDomainObject = jasmine.createSpyObj( mockDomainObject = jasmine.createSpyObj(
"domainObject", "domainObject",
@ -55,30 +51,31 @@ define(
[ "preventDefault" ] [ "preventDefault" ]
); );
mockContextMenuAction = jasmine.createSpyObj( mockContextMenuAction = jasmine.createSpyObj(
"menu", "action",
[ "perform", "destroy" ] [ "perform", "getActions" ]
);
mockActionContext = jasmine.createSpyObj(
"actionContext",
[ "" ]
); );
mockActionContext = {key: 'menu', domainObject: mockDomainObject, event: mockEvent};
mockActionContext.domainObject = mockDomainObject;
mockActionContext.event = mockEvent;
mockScope.domainObject = mockDomainObject; mockScope.domainObject = mockDomainObject;
mockDomainObject.getCapability.andReturn(function (c) { mockDomainObject.getCapability.andReturn(mockContextMenuAction);
//return c === 'action' ? mockContextMenuAction : undefined; mockContextMenuAction.perform.andReturn(jasmine.any(Function));
return mockContextMenuAction;
});
controller = new MenuArrowController(mockScope); controller = new MenuArrowController(mockScope);
}); });
it(" calls the context menu action when clicked", function () { it("calls the context menu action when clicked", function () {
// Simulate a click on the menu arrow // Simulate a click on the menu arrow
controller.showMenu(mockEvent); controller.showMenu(mockEvent);
//stop = $scope.domainObject.getCapability('action').perform(actionContext); // Expect the menu action to be performed
expect(mockDomainObject.getCapability).toHaveBeenCalledWith('action');
expect(mockDomainObject.getCapability).toHaveBeenCalled(); expect(mockContextMenuAction.perform).toHaveBeenCalled();
//.toHaveBeenCalledWith('action');
}); });
}); });
} }
); );

View File

@ -70,26 +70,6 @@ define(
mockDomainObject.calls mockDomainObject.calls
); );
}); });
////// Is this one here or in action spec? (shale)
/*
it("removes listeners from body if destroyed while menu is showing", function () {
// Show the menu
fireGesture(mockEvent);
// Verify preconditions
expect(mockBody.off).not.toHaveBeenCalled();
expect(mockMenu.remove).not.toHaveBeenCalled();
// Destroy the menu
gesture.destroy();
// Verify menu was removed and listener detached
expect(mockBody.off).toHaveBeenCalled();
expect(mockMenu.remove).toHaveBeenCalled();
});
*/
}); });
} }
); );