2014-11-25 01:01:37 +00:00
|
|
|
/*global define,describe,it,expect,beforeEach,jasmine*/
|
|
|
|
|
|
|
|
define(
|
2015-02-27 01:05:13 +00:00
|
|
|
["../../src/controllers/EditActionController"],
|
2014-11-25 01:01:37 +00:00
|
|
|
function (EditActionController) {
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
describe("The Edit Action controller", function () {
|
2014-11-25 01:29:42 +00:00
|
|
|
var mockScope,
|
|
|
|
mockActions,
|
|
|
|
controller;
|
2014-11-25 01:01:37 +00:00
|
|
|
|
2014-11-25 01:29:42 +00:00
|
|
|
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);
|
|
|
|
});
|
2014-11-25 01:01:37 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|