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

View File

@ -70,26 +70,6 @@ define(
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();
});
*/
});
}
);