[Common UI] Specs for edit controllers

Add specs for controllers used to support Edit mode,
one of the common UI elements being transitioned for
WTD-574.
This commit is contained in:
Victor Woeltjen
2014-11-24 17:29:42 -08:00
parent 093ccb637f
commit d7fbd596ef
3 changed files with 100 additions and 0 deletions

View File

@ -6,7 +6,35 @@ define(
"use strict";
describe("The Edit Action controller", function () {
var mockScope,
mockActions,
controller;
beforeEach(function () {
mockActions = jasmine.createSpyObj("action", ["getActions"]);
mockScope = jasmine.createSpyObj("$scope", ["$watch"]);
controller = new EditActionController(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;
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.editActions.length).toEqual(3);
});
});
}
);