2015-06-24 18:32:59 +00:00
|
|
|
/*****************************************************************************
|
2018-05-14 22:46:17 +00:00
|
|
|
* Open MCT, Copyright (c) 2014-2018, United States Government
|
2015-06-24 18:32:59 +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-24 18:32:59 +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-24 18:32:59 +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.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* MCTRepresentationSpec. Created by vwoeltje on 11/6/14.
|
|
|
|
*/
|
|
|
|
define(
|
|
|
|
["../../src/services/UrlService"],
|
|
|
|
function (UrlService) {
|
|
|
|
|
|
|
|
describe("The url service", function () {
|
2015-06-24 19:50:21 +00:00
|
|
|
var urlService,
|
2015-06-25 17:10:13 +00:00
|
|
|
mockLocation,
|
|
|
|
mockDomainObject,
|
|
|
|
mockContext,
|
|
|
|
mockMode,
|
|
|
|
testViews;
|
2015-06-24 18:32:59 +00:00
|
|
|
|
|
|
|
beforeEach(function () {
|
2016-05-19 18:29:13 +00:00
|
|
|
// Creates a mockLocation, used to
|
2015-06-24 19:50:21 +00:00
|
|
|
// do the view search
|
2015-06-24 18:32:59 +00:00
|
|
|
mockLocation = jasmine.createSpyObj(
|
|
|
|
"$location",
|
2016-05-19 18:29:13 +00:00
|
|
|
["path", "search"]
|
2015-06-24 18:32:59 +00:00
|
|
|
);
|
2016-05-19 18:29:13 +00:00
|
|
|
|
|
|
|
// The mockDomainObject is initialized as a
|
2015-06-24 19:50:21 +00:00
|
|
|
// spy object to ultimately be passed into the
|
|
|
|
// urlService urlFor function
|
2015-06-25 17:10:13 +00:00
|
|
|
mockDomainObject = jasmine.createSpyObj(
|
2015-06-24 18:32:59 +00:00
|
|
|
"domainObject",
|
2016-05-19 18:29:13 +00:00
|
|
|
["getId", "getCapability", "getModel", "useCapability"]
|
2015-06-25 17:10:13 +00:00
|
|
|
);
|
|
|
|
mockContext = jasmine.createSpyObj('context', ['getPath']);
|
|
|
|
testViews = [
|
|
|
|
{ key: 'abc' },
|
|
|
|
{ key: 'def', someKey: 'some value' },
|
|
|
|
{ key: 'xyz' }
|
|
|
|
];
|
|
|
|
mockMode = "browse";
|
2016-05-19 18:29:13 +00:00
|
|
|
|
2015-06-24 19:50:21 +00:00
|
|
|
// The mockContext is set a path
|
|
|
|
// for the mockDomainObject
|
2018-06-30 00:32:59 +00:00
|
|
|
mockContext.getPath.and.returnValue(
|
2015-06-24 19:31:40 +00:00
|
|
|
[mockDomainObject]
|
|
|
|
);
|
2016-05-19 18:29:13 +00:00
|
|
|
|
2015-06-24 19:50:21 +00:00
|
|
|
// view capability used with the testviews made
|
2018-06-30 00:32:59 +00:00
|
|
|
mockDomainObject.useCapability.and.callFake(function (c) {
|
2015-06-24 18:32:59 +00:00
|
|
|
return (c === 'view') && testViews;
|
|
|
|
});
|
2016-05-19 18:29:13 +00:00
|
|
|
|
2015-06-24 19:50:21 +00:00
|
|
|
// context capability used with the mockContext created
|
|
|
|
// so the variables including context in the urlFor are
|
|
|
|
// initialized and reached
|
2018-06-30 00:32:59 +00:00
|
|
|
mockDomainObject.getCapability.and.callFake(function (c) {
|
2015-06-24 19:31:40 +00:00
|
|
|
return c === 'context' && mockContext;
|
|
|
|
});
|
2016-05-19 18:29:13 +00:00
|
|
|
|
2015-06-24 19:50:21 +00:00
|
|
|
// Uses the mockLocation to get the current
|
|
|
|
// "mock" website's view
|
2018-06-30 00:32:59 +00:00
|
|
|
mockLocation.search.and.returnValue({ view: 'def' });
|
2016-05-19 18:29:13 +00:00
|
|
|
|
2015-06-25 17:10:13 +00:00
|
|
|
urlService = new UrlService(mockLocation);
|
|
|
|
});
|
2016-05-19 18:29:13 +00:00
|
|
|
|
2015-06-25 17:10:13 +00:00
|
|
|
it("get url for a location using domainObject and mode", function () {
|
|
|
|
urlService.urlForLocation(mockMode, mockDomainObject);
|
2015-06-24 18:32:59 +00:00
|
|
|
});
|
2016-05-19 18:29:13 +00:00
|
|
|
|
2015-06-25 17:10:13 +00:00
|
|
|
it("get url for a new tab using domainObject and mode", function () {
|
|
|
|
urlService.urlForNewTab(mockMode, mockDomainObject);
|
2015-07-23 16:28:36 +00:00
|
|
|
});
|
2015-06-24 18:32:59 +00:00
|
|
|
});
|
|
|
|
}
|
2016-05-19 18:29:13 +00:00
|
|
|
);
|