mirror of
https://github.com/nasa/openmct.git
synced 2025-01-02 19:36:41 +00:00
2b1fdc2204
Add specs for controllers in the commonUI/general bundle. WTD-574.
41 lines
1.4 KiB
JavaScript
41 lines
1.4 KiB
JavaScript
/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/
|
|
|
|
define(
|
|
["../src/ContextMenuController"],
|
|
function (ContextMenuController) {
|
|
"use strict";
|
|
|
|
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);
|
|
});
|
|
});
|
|
}
|
|
); |