RIFT-15726 - optimize download size -> lodash usage in UI
[osm/UI.git] / skyquake / plugins / composer / test / spec / libraries / DescriptorModelSpec.js
1 /*
2 *
3 * Copyright 2016 RIFT.IO Inc
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
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,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 */
18 /**
19 * Created by onvelocity on 2/8/16.
20 */
21 /*global describe, beforeEach, it, expect, xit */
22
23 'use strict';
24 import DescriptorModel from 'libraries/model/DescriptorModel'
25
26 class TestDescriptorModel extends DescriptorModel {
27 constructor(model, parent) {
28 super(model, parent);
29 }
30 }
31 describe('DescriptorModel', () => {
32 let parent, child1, child2;
33 beforeEach(() => {
34 parent = new TestDescriptorModel({name: 'parent 1'});
35 child1 = new TestDescriptorModel({name: 'child 1'}, parent);
36 child2 = new TestDescriptorModel({name: 'child 2'}, parent);
37 });
38 it('creates a uid and stores it in the uiState field ":uid"', () => {
39 expect(child1.uid).toEqual(child1.model.uiState[':uid']);
40 });
41 describe('.constructor(model, parent)', () => {
42 it('creates child when parent is given on constructor', () => {
43 const child = new TestDescriptorModel({name: 'test1'}, parent);
44 expect(parent.children).toContain(child);
45 });
46 });
47 describe('.findChildByUid', () => {
48 it('finds an existing child', () => {
49 const result = parent.findChildByUid(child2.uid);
50 expect(result).toBe(child2);
51 });
52 });
53 });