2015-05-13 23:42:35 +00:00
|
|
|
/*****************************************************************************
|
2017-04-05 21:35:12 +00:00
|
|
|
* Open MCT, Copyright (c) 2014-2017, United States Government
|
2015-05-13 23:42:35 +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-05-13 23:42:35 +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-05-13 23:42:35 +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.
|
|
|
|
*****************************************************************************/
|
2014-11-24 21:39:52 +00:00
|
|
|
|
|
|
|
define(
|
2014-12-30 21:40:42 +00:00
|
|
|
["../../src/directives/MCTContainer"],
|
2014-11-24 21:39:52 +00:00
|
|
|
function (MCTContainer) {
|
|
|
|
|
|
|
|
describe("The mct-container directive", function () {
|
2014-11-24 23:22:03 +00:00
|
|
|
var testContainers = [
|
|
|
|
{
|
|
|
|
bundle: { path: "a", resources: "b" },
|
2016-02-27 00:17:33 +00:00
|
|
|
template: "<div>foo</div>",
|
2014-11-24 23:22:03 +00:00
|
|
|
key: "abc"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
bundle: { path: "x", resources: "y" },
|
2016-02-27 00:17:33 +00:00
|
|
|
template: "<span>bar</span>",
|
2014-11-24 23:22:03 +00:00
|
|
|
key: "xyz",
|
2016-05-19 18:29:13 +00:00
|
|
|
attributes: ["someAttr", "someOtherAttr"]
|
2014-11-24 23:22:03 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
mctContainer;
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
mctContainer = new MCTContainer(testContainers);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("is applicable to elements", function () {
|
|
|
|
expect(mctContainer.restrict).toEqual("E");
|
|
|
|
});
|
|
|
|
|
|
|
|
it("creates a new (non-isolate) scope", function () {
|
|
|
|
expect(mctContainer.scope).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("chooses a template based on key", function () {
|
2016-02-27 00:17:33 +00:00
|
|
|
expect(mctContainer.template(
|
2014-11-24 23:22:03 +00:00
|
|
|
undefined,
|
|
|
|
{ key: "abc" }
|
2016-02-27 00:17:33 +00:00
|
|
|
)).toEqual(testContainers[0].template);
|
2014-11-24 23:22:03 +00:00
|
|
|
|
2016-02-27 00:17:33 +00:00
|
|
|
expect(mctContainer.template(
|
2014-11-24 23:22:03 +00:00
|
|
|
undefined,
|
|
|
|
{ key: "xyz" }
|
2016-02-27 00:17:33 +00:00
|
|
|
)).toEqual(testContainers[1].template);
|
2014-11-24 23:22:03 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("copies attributes needed by the container", function () {
|
|
|
|
var scope = {};
|
|
|
|
|
|
|
|
mctContainer.link(
|
|
|
|
scope,
|
|
|
|
undefined,
|
|
|
|
{
|
|
|
|
key: "xyz",
|
|
|
|
someAttr: "some value",
|
|
|
|
someOtherAttr: "some other value",
|
|
|
|
someExtraAttr: "should not be present"
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(scope.container.someAttr).toEqual("some value");
|
|
|
|
expect(scope.container.someOtherAttr).toEqual("some other value");
|
|
|
|
expect(scope.container.someExtraAttr).toBeUndefined();
|
|
|
|
});
|
|
|
|
|
2014-11-24 21:39:52 +00:00
|
|
|
});
|
|
|
|
}
|
2016-05-19 18:29:13 +00:00
|
|
|
);
|