[Common UI] Continue filling in Browse specs

Continue filling in specs for scripts introduced as part
of bundle platform/commonUI/browse, which is responsible
for browse mode. WTD-574.
This commit is contained in:
Victor Woeltjen
2014-11-25 20:26:37 -08:00
parent 528f6bdf56
commit 48ff8c4c03
5 changed files with 311 additions and 2 deletions

View File

@ -5,11 +5,42 @@
*/
define(
["../../src/creation/CreateMenuController"],
function (CreateActionProvider) {
function (CreateMenuController) {
"use strict";
describe("The create menu controller", function () {
var mockScope,
mockActions,
controller;
beforeEach(function () {
mockActions = jasmine.createSpyObj("action", ["getActions"]);
mockScope = jasmine.createSpyObj("$scope", ["$watch"]);
controller = new CreateMenuController(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 create 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.createActions.length).toEqual(3);
// Make sure the right action type was requested
expect(mockActions.getActions).toHaveBeenCalledWith("create");
});
});
}
);