[Common UI] Add specs for controllers

Add specs for controllers in the commonUI/general bundle.
WTD-574.
This commit is contained in:
Victor Woeltjen
2014-11-24 15:10:29 -08:00
parent b026e313be
commit 2b1fdc2204
8 changed files with 344 additions and 20 deletions

View File

@ -5,7 +5,37 @@ define(
function (ContextMenuController) {
"use strict";
describe("The domain object provider", function () {
describe("The context menu controller", function () {
var mockScope,
mockActions,
controller;
beforeEach(function () {
mockActions = jasmine.createSpyObj("action", ["getActions"]);
mockScope = jasmine.createSpyObj("$scope", ["$watch"]);
controller = new ContextMenuController(mockScope);
});
it("watches scope that may change applicable actions", function () {
// The action capability
expect(mockScope.$watch).toHaveBeenCalledWith(
"action",
jasmine.any(Function)
);
});
it("populates the scope with grouped and ungrouped actions", function () {
mockScope.action = mockActions;
mockScope.parameters = { category: "test" };
mockActions.getActions.andReturn(["a", "b", "c"]);
// Call the watch
mockScope.$watch.mostRecentCall.args[1]();
// Should have grouped and ungrouped actions in scope now
expect(mockScope.menuActions.length).toEqual(3);
});
});
}
);