2015-07-02 19:50:48 +00:00
|
|
|
/*****************************************************************************
|
2017-04-05 21:35:12 +00:00
|
|
|
* Open MCT, Copyright (c) 2014-2017, United States Government
|
2015-07-02 19:50:48 +00:00
|
|
|
* as represented by the Administrator of the National Aeronautics and Space
|
|
|
|
* Administration. All rights reserved.
|
|
|
|
*
|
2016-07-12 23:21:58 +00:00
|
|
|
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
2015-07-02 19:50:48 +00:00
|
|
|
* "License"); you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*
|
2016-07-12 23:21:58 +00:00
|
|
|
* Open MCT includes source code licensed under additional open source
|
2015-07-02 19:50:48 +00:00
|
|
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
|
|
|
* this source code distribution or the Licensing information page available
|
|
|
|
* at runtime from the About dialog for additional information.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* MenuArrowControllerSpec. Created by shale on 07/02/2015.
|
|
|
|
*/
|
|
|
|
define(
|
2015-07-02 21:00:54 +00:00
|
|
|
["../src/MenuArrowController"],
|
|
|
|
function (MenuArrowController) {
|
2016-05-19 18:29:13 +00:00
|
|
|
|
2015-07-07 16:28:01 +00:00
|
|
|
describe("The menu arrow controller ", function () {
|
2015-07-02 19:50:48 +00:00
|
|
|
var mockScope,
|
|
|
|
mockDomainObject,
|
2015-07-02 21:00:54 +00:00
|
|
|
mockEvent,
|
|
|
|
mockContextMenuAction,
|
|
|
|
mockActionContext,
|
2015-07-02 19:50:48 +00:00
|
|
|
controller;
|
2016-05-19 18:29:13 +00:00
|
|
|
|
2015-07-02 19:50:48 +00:00
|
|
|
beforeEach(function () {
|
|
|
|
mockScope = jasmine.createSpyObj(
|
|
|
|
"$scope",
|
2016-05-19 18:29:13 +00:00
|
|
|
[""]
|
2015-07-02 19:50:48 +00:00
|
|
|
);
|
|
|
|
mockDomainObject = jasmine.createSpyObj(
|
|
|
|
"domainObject",
|
2016-05-19 18:29:13 +00:00
|
|
|
["getCapability"]
|
2015-07-02 19:50:48 +00:00
|
|
|
);
|
2015-07-02 21:00:54 +00:00
|
|
|
mockEvent = jasmine.createSpyObj(
|
|
|
|
"event",
|
2016-05-19 18:29:13 +00:00
|
|
|
["preventDefault"]
|
2015-07-02 19:50:48 +00:00
|
|
|
);
|
2015-07-02 21:00:54 +00:00
|
|
|
mockContextMenuAction = jasmine.createSpyObj(
|
2015-07-07 16:28:01 +00:00
|
|
|
"action",
|
2016-05-19 18:29:13 +00:00
|
|
|
["perform", "getActions"]
|
2015-07-07 16:28:01 +00:00
|
|
|
);
|
|
|
|
mockActionContext = jasmine.createSpyObj(
|
|
|
|
"actionContext",
|
2016-05-19 18:29:13 +00:00
|
|
|
[""]
|
2015-07-02 19:50:48 +00:00
|
|
|
);
|
2016-05-19 18:29:13 +00:00
|
|
|
|
2015-07-07 16:28:01 +00:00
|
|
|
mockActionContext.domainObject = mockDomainObject;
|
|
|
|
mockActionContext.event = mockEvent;
|
2015-07-02 21:00:54 +00:00
|
|
|
mockScope.domainObject = mockDomainObject;
|
2015-07-07 16:28:01 +00:00
|
|
|
mockDomainObject.getCapability.andReturn(mockContextMenuAction);
|
|
|
|
mockContextMenuAction.perform.andReturn(jasmine.any(Function));
|
2016-05-19 18:29:13 +00:00
|
|
|
|
2015-07-02 21:00:54 +00:00
|
|
|
controller = new MenuArrowController(mockScope);
|
|
|
|
});
|
2016-05-19 18:29:13 +00:00
|
|
|
|
2015-07-07 16:28:01 +00:00
|
|
|
it("calls the context menu action when clicked", function () {
|
2015-07-02 21:00:54 +00:00
|
|
|
// Simulate a click on the menu arrow
|
|
|
|
controller.showMenu(mockEvent);
|
2016-05-19 18:29:13 +00:00
|
|
|
|
|
|
|
// Expect the menu action to be performed
|
2015-07-07 16:28:01 +00:00
|
|
|
expect(mockDomainObject.getCapability).toHaveBeenCalledWith('action');
|
|
|
|
expect(mockContextMenuAction.perform).toHaveBeenCalled();
|
2015-07-02 19:50:48 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|