2015-06-22 22:10:55 +00:00
|
|
|
/*****************************************************************************
|
2018-05-14 22:46:17 +00:00
|
|
|
* Open MCT, Copyright (c) 2014-2018, United States Government
|
2015-06-22 22:10:55 +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-06-22 22:10:55 +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-06-22 22:10:55 +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.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
define(
|
2015-06-22 22:44:09 +00:00
|
|
|
["../../src/windowing/NewTabAction"],
|
|
|
|
function (NewTabAction) {
|
2016-05-19 18:29:13 +00:00
|
|
|
|
2015-06-22 22:35:08 +00:00
|
|
|
describe("The new tab action", function () {
|
2015-06-24 19:50:21 +00:00
|
|
|
var actionSelected,
|
|
|
|
actionCurrent,
|
2015-06-22 22:10:55 +00:00
|
|
|
mockWindow,
|
2015-06-24 19:50:21 +00:00
|
|
|
mockContextCurrent,
|
|
|
|
mockContextSelected,
|
2015-06-24 18:32:59 +00:00
|
|
|
mockUrlService;
|
2015-06-22 22:10:55 +00:00
|
|
|
|
|
|
|
beforeEach(function () {
|
2015-06-24 18:32:59 +00:00
|
|
|
mockWindow = jasmine.createSpyObj("$window", ["open", "location"]);
|
|
|
|
|
2015-06-24 19:50:21 +00:00
|
|
|
// Context if the current object is selected
|
|
|
|
// For example, when the top right new tab
|
2016-05-19 18:29:13 +00:00
|
|
|
// button is clicked, the user is using the
|
2015-06-24 19:50:21 +00:00
|
|
|
// current domainObject
|
|
|
|
mockContextCurrent = jasmine.createSpyObj("context", ["domainObject"]);
|
2016-05-19 18:29:13 +00:00
|
|
|
|
2015-06-24 19:50:21 +00:00
|
|
|
// Context if the selected object is selected
|
|
|
|
// For example, when an object in the left
|
|
|
|
// tree is opened in a new tab using the
|
|
|
|
// context menu
|
|
|
|
mockContextSelected = jasmine.createSpyObj("context", ["selectedObject",
|
|
|
|
"domainObject"]);
|
2016-05-19 18:29:13 +00:00
|
|
|
|
2015-06-24 19:50:21 +00:00
|
|
|
// Mocks the urlService used to make the new tab's url from a
|
|
|
|
// domainObject and mode
|
2015-06-25 17:10:13 +00:00
|
|
|
mockUrlService = jasmine.createSpyObj("urlService", ["urlForNewTab"]);
|
2016-05-19 18:29:13 +00:00
|
|
|
|
2015-06-24 19:50:21 +00:00
|
|
|
// Action done using the current context or mockContextCurrent
|
|
|
|
actionCurrent = new NewTabAction(mockUrlService, mockWindow,
|
|
|
|
mockContextCurrent);
|
2016-05-19 18:29:13 +00:00
|
|
|
|
2015-06-24 19:50:21 +00:00
|
|
|
// Action done using the selected context or mockContextSelected
|
|
|
|
actionSelected = new NewTabAction(mockUrlService, mockWindow,
|
|
|
|
mockContextSelected);
|
2016-05-19 18:29:13 +00:00
|
|
|
|
2015-06-22 22:10:55 +00:00
|
|
|
});
|
2016-05-19 18:29:13 +00:00
|
|
|
|
2015-06-24 19:54:49 +00:00
|
|
|
it("new tab with current url is opened", function () {
|
2015-06-24 19:50:21 +00:00
|
|
|
actionCurrent.perform();
|
|
|
|
});
|
2016-05-19 18:29:13 +00:00
|
|
|
|
2015-06-24 19:54:49 +00:00
|
|
|
it("new tab with a selected url is opened", function () {
|
2015-06-24 19:50:21 +00:00
|
|
|
actionSelected.perform();
|
2015-06-22 22:10:55 +00:00
|
|
|
});
|
2016-05-19 18:29:13 +00:00
|
|
|
|
2015-06-22 22:10:55 +00:00
|
|
|
});
|
|
|
|
}
|
2016-05-19 18:29:13 +00:00
|
|
|
);
|