|
| 1 | +/***************************************************************************** |
| 2 | + * Open MCT, Copyright (c) 2014-2016, United States Government |
| 3 | + * as represented by the Administrator of the National Aeronautics and Space |
| 4 | + * Administration. All rights reserved. |
| 5 | + * |
| 6 | + * Open MCT is licensed under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0. |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 14 | + * License for the specific language governing permissions and limitations |
| 15 | + * under the License. |
| 16 | + * |
| 17 | + * Open MCT includes source code licensed under additional open source |
| 18 | + * licenses. See the Open Source Licenses file (LICENSES.md) included with |
| 19 | + * this source code distribution or the Licensing information page available |
| 20 | + * at runtime from the About dialog for additional information. |
| 21 | + *****************************************************************************/ |
| 22 | + |
| 23 | +define([ |
| 24 | + './MCT', |
| 25 | + './plugins/plugins', |
| 26 | + 'legacyRegistry' |
| 27 | +], function (MCT, plugins, legacyRegistry) { |
| 28 | + describe("MCT", function () { |
| 29 | + var openmct; |
| 30 | + var mockPlugin; |
| 31 | + var mockPlugin2; |
| 32 | + var mockListener; |
| 33 | + var oldBundles; |
| 34 | + |
| 35 | + beforeEach(function () { |
| 36 | + mockPlugin = jasmine.createSpy('plugin'); |
| 37 | + mockPlugin2 = jasmine.createSpy('plugin2'); |
| 38 | + mockListener = jasmine.createSpy('listener'); |
| 39 | + oldBundles = legacyRegistry.list(); |
| 40 | + |
| 41 | + openmct = new MCT(); |
| 42 | + |
| 43 | + openmct.install(mockPlugin); |
| 44 | + openmct.install(mockPlugin2); |
| 45 | + openmct.on('start', mockListener); |
| 46 | + }); |
| 47 | + |
| 48 | + // Clean up the dirty singleton. |
| 49 | + afterEach(function () { |
| 50 | + legacyRegistry.list().forEach(function (bundle) { |
| 51 | + if (oldBundles.indexOf(bundle) === -1) { |
| 52 | + legacyRegistry.delete(bundle); |
| 53 | + } |
| 54 | + }); |
| 55 | + }); |
| 56 | + |
| 57 | + it("exposes plugins", function () { |
| 58 | + expect(openmct.plugins).toEqual(plugins); |
| 59 | + }); |
| 60 | + |
| 61 | + it("does not issue a start event before started", function () { |
| 62 | + expect(mockListener).not.toHaveBeenCalled(); |
| 63 | + }); |
| 64 | + |
| 65 | + describe("start", function () { |
| 66 | + beforeEach(function () { |
| 67 | + openmct.start(); |
| 68 | + }); |
| 69 | + |
| 70 | + it("calls plugins for configuration", function () { |
| 71 | + expect(mockPlugin).toHaveBeenCalledWith(openmct); |
| 72 | + expect(mockPlugin2).toHaveBeenCalledWith(openmct); |
| 73 | + }); |
| 74 | + |
| 75 | + it("emits a start event", function () { |
| 76 | + expect(mockListener).toHaveBeenCalled(); |
| 77 | + }); |
| 78 | + }); |
| 79 | + |
| 80 | + describe("setAssetPath", function () { |
| 81 | + var testAssetPath; |
| 82 | + |
| 83 | + beforeEach(function () { |
| 84 | + testAssetPath = "some/path"; |
| 85 | + openmct.legacyExtension = jasmine.createSpy('legacyExtension'); |
| 86 | + openmct.setAssetPath(testAssetPath); |
| 87 | + }); |
| 88 | + |
| 89 | + it("internally configures the path for assets", function () { |
| 90 | + expect(openmct.legacyExtension).toHaveBeenCalledWith( |
| 91 | + 'constants', |
| 92 | + { |
| 93 | + key: "ASSETS_PATH", |
| 94 | + value: testAssetPath |
| 95 | + } |
| 96 | + ); |
| 97 | + }); |
| 98 | + }); |
| 99 | + }); |
| 100 | +}); |
0 commit comments