openmct/platform/commonUI/general/test/ui/TreeViewSpec.js

305 lines
11 KiB
JavaScript
Raw Normal View History

2016-03-14 19:22:09 +00:00
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2016, United States Government
2016-03-14 19:22:09 +00:00
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
2016-03-14 19:22:09 +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.
*
* Open MCT includes source code licensed under additional open source
2016-03-14 19:22:09 +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.
*****************************************************************************/
2016-05-09 17:19:24 +00:00
/*global describe,beforeEach,jasmine,it,expect*/
2016-03-14 19:22:09 +00:00
define([
2016-03-14 20:04:46 +00:00
'../../src/ui/TreeView',
'zepto'
], function (TreeView, $) {
2016-03-14 19:22:09 +00:00
describe("TreeView", function () {
var mockGestureService,
mockGestureHandle,
2016-03-14 19:52:33 +00:00
mockDomainObject,
mockMutation,
mockUnlisten,
testCapabilities,
2016-03-14 19:22:09 +00:00
treeView;
function makeMockDomainObject(id, model, capabilities) {
var mockDomainObj = jasmine.createSpyObj(
'domainObject-' + id,
[
'getId',
'getModel',
'getCapability',
'hasCapability',
'useCapability'
]
);
mockDomainObj.getId.andReturn(id);
mockDomainObj.getModel.andReturn(model);
mockDomainObj.hasCapability.andCallFake(function (c) {
return !!(capabilities[c]);
});
mockDomainObj.getCapability.andCallFake(function (c) {
return capabilities[c];
});
mockDomainObj.useCapability.andCallFake(function (c) {
return capabilities[c] && capabilities[c].invoke();
});
return mockDomainObj;
}
2016-03-14 19:22:09 +00:00
beforeEach(function () {
mockGestureService = jasmine.createSpyObj(
'gestureService',
['attachGestures']
2016-03-14 19:22:09 +00:00
);
mockGestureHandle = jasmine.createSpyObj('gestures', ['destroy']);
mockGestureService.attachGestures.andReturn(mockGestureHandle);
2016-03-14 19:52:33 +00:00
mockMutation = jasmine.createSpyObj('mutation', ['listen']);
mockUnlisten = jasmine.createSpy('unlisten');
mockMutation.listen.andReturn(mockUnlisten);
testCapabilities = { mutation: mockMutation };
mockDomainObject =
makeMockDomainObject('parent', {}, testCapabilities);
2016-03-14 19:52:33 +00:00
treeView = new TreeView(mockGestureService);
2016-03-14 19:22:09 +00:00
});
describe("elements", function () {
var elements;
beforeEach(function () {
elements = treeView.elements();
});
it("is an unordered list", function () {
expect(elements[0].tagName.toLowerCase())
.toEqual('ul');
});
});
2016-03-14 19:52:33 +00:00
describe("model", function () {
var mockComposition;
2016-03-14 21:40:46 +00:00
function makeGenericCapabilities() {
var mockStatus =
jasmine.createSpyObj('status', ['listen', 'list']);
mockStatus.list.andReturn([]);
2016-03-14 21:40:46 +00:00
return {
context: jasmine.createSpyObj('context', ['getPath']),
[Frontend] Refactor glyphs to classes Squashes #1103, fixes #1047. Squashed commit of the following: commit 0e060f174dd8bc453e7a53ea6bf5517869efaaae Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Fri Jul 29 14:55:34 2016 -0700 [Frontend] Added button to .s-button Fixes #1047 commit 9f74395a797546d6b4c4e501829db105e862ecdb Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Fri Jul 29 14:43:36 2016 -0700 [Frontend] Fixing problems from circleci Fixes #1047 commit 7278c9534c4a6dd7a3d402ecb0eb12d59f102c83 Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Fri Jul 29 14:37:21 2016 -0700 [Frontend] CSS fixes for s-status classes Fixes #1047 Fixed .s-status-editing and s-status-pending; commit 4606d617d14024e6c573c6bfa5434bf761301c3f Merge: d5bff55 59436f7 Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Fri Jul 29 13:58:51 2016 -0700 Merge remote-tracking branch 'origin/master' into frontend-1047 commit d5bff555e0119e84e261c355695b504d64bc369a Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Thu Jul 28 19:09:33 2016 -0700 [Frontend] Updated glyphs used by plot view switcher Fixes #1047 commit b72d82baefa3d47a59dceb97691d66a9b67162c3 Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Thu Jul 28 19:09:00 2016 -0700 [Frontend] Tree styles in left pane and selector-list Fixes #1047 commit af36b9996dcd769d2a0a7d7f1f8a0f9838fd1464 Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Thu Jul 28 18:32:34 2016 -0700 [Frontend] Form validation styling Fixes #1047 <mct-form> must now include class 'validates' to display validation glyph icons; removed 'no-validate' from markup; cleaned up validation scss; commit 69dc893b4b9de29e3d505f7da4d38854db68b770 Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Thu Jul 28 17:11:52 2016 -0700 [Frontend] Glyphs to classes, mobile Fixes #1047 Fixes and enhancements for mobile, particularly in tree; Removed `display: inline-block` from containerSubtle mixin; commit 7bca18b18613273d579af7874936d43fa45bd790 Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Thu Jul 28 11:36:19 2016 -0700 [Frontend] Rename .s-menu-btn, remove unused Fixes #1047 .s-menu-btn > .s-menu-button; .create-btn > .create-button; removed unused l-btn, t-btn, t-btns-zoom from markup commit 5d229198b7343f3de44a052621e76d1f2e263f04 Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Thu Jul 28 11:25:36 2016 -0700 [Frontend] Rename .s-clickable-icon to .s-icon-button Fixes #1047 commit 36479e2e8b9c6e2a28ce03c0b49efbb633193fc5 Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Thu Jul 28 11:20:30 2016 -0700 [Frontend] Rename .s-btn to .s-button Fixes #1047 commit 89e4f06de9f3b8587318c3962390037f4e97ebe2 Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Thu Jul 28 11:12:07 2016 -0700 [Frontend] Apply clickable-icon class Fixes #1047 commit e65ca1cb8b3982124bae433ab973dd531df3b014 Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Thu Jul 28 10:52:35 2016 -0700 [Frontend] Updated icons Fixes #1047 - Clock, timer, plots updated commit 3e7eb98ac2bb4327853ee5307bc1365bd0f26399 Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Wed Jul 27 18:05:06 2016 -0700 [Frontend] Standardizing styles Fixes #1047 - Finessing mini-tab and making able to control per theme; s-clickable and s-toggle-icon classes cleaned up commit 18e08074a8e8c076ac927d3948af2865d88acb2d Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Wed Jul 27 16:33:25 2016 -0700 [Frontend] Tweaks to sass code Fixes #1047 - Splitter and mini-tab-icon elements commit 44fda8d68f682c9ae1e0e0fcdae029246eab0af9 Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Wed Jul 27 09:24:53 2016 -0700 [Frontend] Multiple UI fixes and tweaks Fixes #1047 mini-tabs, splitters and bg-splash updated; moved position of Inspector collapse mini-tab to allow position transition; splitter-sm class added for Timelines; commit 2aee8bc0d864a679df421d9c44ad092577464c75 Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Tue Jul 26 15:53:32 2016 -0700 [Frontend] Updated splash image Fixes #1047 commit 624f09777f8aa39f0965a46806769cd56596bcea Merge: ce7591f 4d2f159 Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Tue Jul 26 15:02:55 2016 -0700 Merge remote-tracking branch 'origin/master' into frontend-1047 commit ce7591f64299f163635808d22181f4c42d782a82 Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Tue Jul 26 11:22:23 2016 -0700 [Frontend] Fixed clock indicator Fixes #1047 Restored no-collapse and float-right properties; commit 5324c8edbabb225a19b1ba8ccb90401a50bcff9f Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Mon Jul 25 18:14:38 2016 -0700 [Frontend] New font and project file Fixes #1047 New font files that were missed in last commit; updated icomoon proj file; fixed missing char codes in glyphs.scss; commit a3b26288837b1ac80003ef1d819939312c8516bf Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Mon Jul 25 17:54:00 2016 -0700 [Frontend] Revised and new icon art Fixes #1047 New icons for overlay and stacked plots; revised art and new description for Fixed Position object; commit 8a41c6dbc724f19a240d08bce1520335dd50a33f Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Mon Jul 25 17:52:41 2016 -0700 [Frontend] Removing glyph definitions Fixes #1047 Updated comment commit eb293b21ebc2604dc0fea97453cfb929743157cf Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Mon Jul 25 11:56:18 2016 -0700 [Frontend] Removing glyph definitions Fixes #1047 Removed commented code commit d8b1fb7781e0b9244a35ca49d382da5cd48f98b9 Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Mon Jul 25 11:17:45 2016 -0700 [Frontend] Removing glyph definitions; updating tests Fixes #1047 Search and removal of "glyph" definitions in bundle and other JS files; updating tests accordingly; commit 650fbcc921d2995b6c0d82087f3e35fa600392e4 Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Mon Jul 25 10:20:33 2016 -0700 [Frontend] Removing glyph definitions; updating tests Fixes #1047 Search and removal of "glyph" definitions in bundle and other JS files; updating tests accordingly; commit 574b8bd5c12ac7e8bb900de34c40d3228acbf9bf Author: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Date: Fri Jul 22 19:11:56 2016 -0700 [Frontend] Updated tests for glyph refactoring Fixes #1047 Fixing test cases commit dd84177441e449f1534b3f528101be221059b11e Author: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Date: Fri Jul 22 18:47:45 2016 -0700 [Frontend] Updated tests and examples for glyph refactoring Fixes #1047 WIP: Fixing test cases: fixed test in Timers that was expecting glyph return; commit 2231f8e12452c9a4cadc9d51e38dafc3231f812d Author: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Date: Thu Jul 21 17:45:20 2016 -0700 [Frontend] Updated tests for glyph refactoring Fixes #1047 Fixing test cases: fixed test in Timers that was expecting glyph return; commit ae59ecfa97615f321900aee3873f1f003b68ed61 Author: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Date: Thu Jul 21 17:38:45 2016 -0700 [Frontend] Fixed style Fixes #1047 WIP: fixed line-height issue for t-item-icon class commit d43bff1445ca0b171bc27e02b54974afca8a736a Author: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Date: Thu Jul 21 17:07:49 2016 -0700 [Frontend] Fixed colors Fixes #1047 WIP: fixed colors and style defs related to clickable icons commit c2db6f880557f1f2f9057d3c9da5ea2105fc9666 Author: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Date: Thu Jul 21 16:32:17 2016 -0700 [Frontend] Fixed colors Fixes #1047 WIP: fixed colors related to changes to btnSubtle mixin; new constants for clickable icons commit a4753c44d17cadc6345f153a3c03b6d0f04f1de5 Author: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Date: Thu Jul 21 15:23:58 2016 -0700 [Frontend] Added new icon-brackets to symbols font Fixes #1047 WIP commit 2704640b940ecfb9ac4d56c11f0b7ff99a3e4fd8 Author: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Date: Thu Jul 21 15:11:28 2016 -0700 [Frontend] Normalize color constants Fixes #1047 Normalize color constant values for themes; consolidated and cleaned up btn-related mixins; fixed hover color issues commit 421286c7e4b926a1b2375d5d8635b1d291b3036d Author: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Date: Thu Jul 21 14:10:13 2016 -0700 [Frontend] Convert new Fixed Position Display from glyphs Fixes #1047 WIP commit a4111f38552926f6043de62f4e3f291d735d7005 Author: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Date: Thu Jul 21 14:07:38 2016 -0700 [Frontend] Refactoring Timeline glyphs, s-btn fixes Fixes #1047 WIP: Timeline-related glyph refactoring; s-btn styles and hover color fixes commit 883f99921591d7efb1fbac784427cfcd6ec9df60 Merge: 9d9cabb 14f1a1f Author: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Date: Thu Jul 21 08:53:23 2016 -0700 Merge remote-tracking branch 'origin/master' into frontend-1047 commit 9d9cabb7607cfc5fa84353e88befa8d2752728c0 Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Tue Jul 19 16:20:20 2016 -0700 [Frontend] Glyph refactoring Fixes #1047 WIP: search, toolbar buttons; mods to flex archetypes commit 28b663ce4119a5d7fd175b1846c5b704c4ea03ad Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Mon Jul 18 14:58:40 2016 -0700 [Frontend] Glyph-related style changes to toolbars and buttons Fixes #1047 Glyph refactoring WIP for toolbar buttons; Timeline glyph refactoring continued commit a9326f572f87319f773e19ce8cff51f6da26d32b Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Mon Jul 18 13:36:45 2016 -0700 [Frontend] Glyph-related style changes to Timelines Fixes #1047 Timeline glyph refactoring; Resource Graph icons in swimlanes now display grayed-out version when not added to the Resource Graph; minor color tweaks commit d6e1737803e1b9ed78aaf8bea89b560d0b953010 Merge: 88054e5 6176ca2 Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Mon Jul 18 10:29:32 2016 -0700 [Frontend] Merge master into frontend-1047 Fixes #1047 Resolved conflict in icomoon.json file commit 88054e5e8e8b374c028d6735f7baf8b654a76d63 Author: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Date: Thu Jun 30 16:55:40 2016 -0700 [Frontend] Refactoring glyphs to classes fixes #1047 In progress: significant mods to pane collapse/expand buttons and symbols, minor tweaks to splitter look, limits glyph definitions commit 7c47343f5c634dc1f5244a7db20995f3954ab928 Author: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Date: Thu Jun 30 16:52:21 2016 -0700 [Frontend] Refactoring glyphs to classes fixes #1047 In progress: updated font files glyphs, mostly for pane collapse icons commit fd00bdce54e58c91e1dcbb098c7923ef98830239 Author: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Date: Thu Jun 30 12:20:55 2016 -0700 [Frontend] Refactoring glyphs to classes fixes #1047 In progress: search menu commit 272b4b649e1e23f089c814b66c9a7601109f244c Author: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Date: Thu Jun 30 12:11:25 2016 -0700 [Frontend] Refactoring glyphs to classes fixes #1047 In progress: moved limits classes out of _contants and into _glyphs; timers, entanglement context menu items, form validation, date picker. commit 95d26e6fe76a7ef875b580f72f63a6601031c939 Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Wed Jun 29 14:18:12 2016 -0700 [Frontend] Refactoring glyphs to classes Fixes #1047 In-progress; limits commit 26b30d96db5ea52cefdad83766dbb8681559ca0f Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Tue Jun 28 17:16:18 2016 -0700 [Frontend] Refactoring glyphs to classes Fixes #1047 In-progress; overlay close, search inputs, messages and message banners, ui-symbol removal in-progress. commit 4e2a01ad85dc2c7643e5d9936ef61bfcfc41f998 Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Tue Jun 28 16:21:05 2016 -0700 [Frontend] Refactoring glyphs to classes Fixes #1047 In-progress; .labeled added to .s-btn, removed .s-icon-btn commit 521db3c3fe6e91f8711c051691697d367ea5eb40 Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Tue Jun 28 16:10:54 2016 -0700 [Frontend] Refactoring glyphs to classes Fixes #1047 In-progress; plot options, imagery buttons, cleanups in buttons.scss, edit-action buttons, .s-btn .no-label class added. commit 8bb8db69e6a22645b418cb5e33b1822de9f30e49 Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Tue Jun 28 14:47:52 2016 -0700 [Frontend] Refactoring glyphs to classes Fixes #1047 In-progress; indicators, notifications, actions, tests commit 53ed0bfb22fbc02d3bad4eff5579b5ae1538638a Author: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Date: Mon Jun 27 17:01:45 2016 -0700 [Frontend] Refactoring glyphs to classes fixes #1047 In progress, really: view icons, timer/clock commit 47dc7f2f6b1678be68a58461d8dcc900a9c242fa Author: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Date: Mon Jun 27 16:13:31 2016 -0700 [Frontend] Refactoring glyphs to classes fixes #1047 In progress: grid items commit 2bd34f71be7e429edbfc2124f49ff87045a6ffdd Author: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Date: Mon Jun 27 15:00:46 2016 -0700 [Frontend] Refactoring glyphs to classes fixes #1047 Context menus and associated actions, custom checkboxes, tree item being edited commit b561d4f60e28577e8e6975df5dbaec88544acbba Author: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Date: Mon Jun 27 14:27:56 2016 -0700 [Frontend] Refactoring glyphs to classes fixes #1047 In-progess: glyphs.scss now uses $vars to allow other scss to use a var instead of string literals; commit 0cf4089620258bd2c4f572e8973ac0b1b716c447 Author: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Date: Mon Jun 27 14:13:59 2016 -0700 [Frontend] Refactoring glyphs to classes fixes #1047 In-progess: tree-labels, unknown objects, object header commit 46cae1090587e1fb35fc581f2ee171d784f1826a Author: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Date: Mon Jun 27 11:41:06 2016 -0700 [Frontend] Refactoring glyphs to classes fixes #1047 In-progess, menus and Create menu fixes commit fe3097707fad9e6cbbddde88f9118deba82185c8 Merge: 7d69ae4 652a50c Author: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Date: Mon Jun 27 11:20:55 2016 -0700 Merge remote-tracking branch 'origin/master' into frontend-1047 commit 7d69ae401b21fece0c959fa99a12dcc7edbc2188 Author: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Date: Thu Jun 23 15:59:56 2016 -0700 [Frontend] Refactoring glyphs to classes fixes #1047 In-progress, converting types, mods to Create Menu template commit 18d9f3d6b2060cf837311187b0355ca45ee934a9 Author: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Date: Thu Jun 23 15:14:22 2016 -0700 [Frontend] Refactoring glyphs to classes fixes #1047 Very much In-progess: convert some controls; commit e93a90a782138b3382270cd984ea2842486eb0cd Author: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Date: Thu Jun 23 11:28:07 2016 -0700 [Frontend] Refactoring glyphs to classes fixes #1047 Very much In-progess, classes for all symbols added to glyphs.scss; .menu cleaned up; commit dc670b22a6a58e9dab019be5f8f33d66c224d113 Author: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Date: Thu Jun 23 08:55:27 2016 -0700 [Frontend] Refactoring glyphs to classes fixes #1047 Very much In-progess, "icon-" selector, browse bar buttons commit 8b29ccf3afe70e73efe90b7558758e4cf9124d9a Author: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Date: Wed Jun 22 23:15:24 2016 -0700 [Frontend] Refactoring glyphs to classes fixes #1047 Very much In-progess, s-btn and s-btn-menu refactoring commit f574ffed1691517ee8dd811fef4ab25898180827 Author: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Date: Wed Jun 22 14:37:34 2016 -0700 [Frontend] Refactoring glyphs to classes fixes #1047 In-progess, e900 > e904 commit bc62ee4565897b86a68bd33fd68a6817e782f790 Author: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Date: Wed Jun 22 13:28:15 2016 -0700 [Frontend] Complete revamp of unicodes fixes #1047 New font files; no re-mapping yet in the app. commit 614f0c6e9f8ce904f67638ecede9ac1e6ed1cbc3 Author: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Date: Wed Jun 22 13:23:18 2016 -0700 [Frontend] Complete revamp of unicodes fixes #1047 Moved all glyphs into PUA area of font, and re-organized by category. commit 47bd4031d56af1e1203315ce9a146de9dfcdf3ad Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Tue Jun 21 18:39:48 2016 -0700 [Frontend] Renaming symbols font files Fixes #1047 - Modified sass to point to renamed font files; - Added new 12px symbols font files to sass; commit 22a51d6bbbedb6f5389e5ede37d8ab131460c205 Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Tue Jun 21 18:22:33 2016 -0700 [Frontend] Updating Icomoon project files Fixes #1047 - Renamed main project file; - Added new 12px symbols project file; commit 13ded2fd8482ff1eb3fe95bbe225147adf29024c Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Tue Jun 21 18:19:27 2016 -0700 [Frontend] Added new 12px symbols font files Fixes #1047 commit aef5660dfd9303178014b7c77442f7541c0f26f8 Author: Charles Hacskaylo <charlesh88@gmail.com> Date: Tue Jun 21 18:16:56 2016 -0700 [Frontend] Renaming symbols font files Fixes #1047
2016-08-01 21:33:25 +00:00
type: jasmine.createSpyObj('type', ['getCssClass']),
location: jasmine.createSpyObj('location', ['isLink']),
mutation: jasmine.createSpyObj('mutation', ['listen']),
status: mockStatus
2016-03-14 21:40:46 +00:00
};
}
2016-03-14 19:52:33 +00:00
function waitForCompositionCallback() {
2016-03-14 21:40:46 +00:00
var calledBack = false;
testCapabilities.composition.invoke().then(function () {
2016-03-14 19:52:33 +00:00
calledBack = true;
});
waitsFor(function () {
return calledBack;
});
}
beforeEach(function () {
mockComposition = ['a', 'b', 'c'].map(function (id) {
var testCaps = makeGenericCapabilities(),
2016-03-14 21:40:46 +00:00
mockChild =
makeMockDomainObject(id, {}, testCaps);
testCaps.context.getPath
2016-03-14 20:04:46 +00:00
.andReturn([mockDomainObject, mockChild]);
2016-03-14 20:04:46 +00:00
return mockChild;
2016-03-14 19:52:33 +00:00
});
testCapabilities.composition =
jasmine.createSpyObj('composition', ['invoke']);
2016-03-14 19:52:33 +00:00
testCapabilities.composition.invoke
.andReturn(Promise.resolve(mockComposition));
treeView.model(mockDomainObject);
waitForCompositionCallback();
});
it("adds one node per composition element", function () {
expect(treeView.elements()[0].childElementCount)
.toEqual(mockComposition.length);
});
it("listens for mutation", function () {
expect(testCapabilities.mutation.listen)
.toHaveBeenCalledWith(jasmine.any(Function));
});
describe("when mutation occurs", function () {
beforeEach(function () {
mockComposition.pop();
testCapabilities.mutation.listen
.mostRecentCall.args[0](mockDomainObject.getModel());
2016-03-14 19:52:33 +00:00
waitForCompositionCallback();
});
it("continues to show one node per composition element", function () {
expect(treeView.elements()[0].childElementCount)
.toEqual(mockComposition.length);
});
});
describe("when replaced with a non-compositional domain object", function () {
beforeEach(function () {
delete testCapabilities.composition;
treeView.model(mockDomainObject);
});
it("stops listening for mutation", function () {
expect(mockUnlisten).toHaveBeenCalled();
});
it("removes all tree nodes", function () {
expect(treeView.elements()[0].childElementCount)
.toEqual(0);
});
});
2016-03-14 20:04:46 +00:00
describe("when selection state changes", function () {
var selectionIndex = 1;
beforeEach(function () {
treeView.value(mockComposition[selectionIndex]);
});
it("communicates selection state to an appropriate node", function () {
var selected = $(treeView.elements()[0]).find('.selected');
expect(selected.length).toEqual(1);
});
});
2016-03-14 21:40:46 +00:00
describe("when a context-less object is selected", function () {
beforeEach(function () {
var testCaps = makeGenericCapabilities(),
mockDomainObj =
makeMockDomainObject('xyz', {}, testCaps);
delete testCaps.context;
treeView.value(mockDomainObj);
});
it("clears all selection state", function () {
var selected = $(treeView.elements()[0]).find('.selected');
expect(selected.length).toEqual(0);
});
});
2016-03-14 21:40:46 +00:00
describe("when children contain children", function () {
beforeEach(function () {
var newCapabilities = makeGenericCapabilities(),
gcCapabilities = makeGenericCapabilities(),
mockNewChild =
makeMockDomainObject('d', {}, newCapabilities),
mockGrandchild =
makeMockDomainObject('gc', {}, gcCapabilities),
calledBackInner = false;
newCapabilities.composition =
jasmine.createSpyObj('composition', ['invoke']);
2016-03-14 21:40:46 +00:00
newCapabilities.composition.invoke
.andReturn(Promise.resolve([mockGrandchild]));
mockComposition.push(mockNewChild);
newCapabilities.context.getPath.andReturn([
mockDomainObject,
mockNewChild
]);
gcCapabilities.context.getPath.andReturn([
mockDomainObject,
mockNewChild,
mockGrandchild
]);
testCapabilities.mutation.listen
.mostRecentCall.args[0](mockDomainObject);
waitForCompositionCallback();
runs(function () {
// Select the innermost object to force expansion,
// such that we can verify the subtree is present.
treeView.value(mockGrandchild);
newCapabilities.composition.invoke().then(function () {
calledBackInner = true;
});
});
waitsFor(function () {
return calledBackInner;
});
});
it("creates inner trees", function () {
expect($(treeView.elements()[0]).find('ul').length)
.toEqual(1);
});
});
describe("when status changes", function () {
var testStatuses;
beforeEach(function () {
var mockStatus = mockComposition[1].getCapability('status');
testStatuses = ['foo'];
mockStatus.list.andReturn(testStatuses);
mockStatus.listen.mostRecentCall.args[0](testStatuses);
});
it("reflects the status change in the tree", function () {
expect($(treeView.elements()).find('.s-status-foo').length)
.toEqual(1);
});
});
2016-03-14 19:52:33 +00:00
});
describe("observe", function () {
var mockCallback,
unobserve;
beforeEach(function () {
mockCallback = jasmine.createSpy('callback');
unobserve = treeView.observe(mockCallback);
});
it("notifies listeners when value is changed", function () {
treeView.value(mockDomainObject);
expect(mockCallback).toHaveBeenCalledWith(mockDomainObject);
});
it("does not notify listeners when deactivated", function () {
unobserve();
treeView.value(mockDomainObject);
expect(mockCallback).not.toHaveBeenCalled();
});
});
2016-03-14 19:22:09 +00:00
});
});