5388780a86987cf419fb41d219698e97cf5457b3
[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 _ from 'lodash'
25 import DescriptorModel from 'libraries/model/DescriptorModel'
26
27 class TestDescriptorModel extends DescriptorModel {
28 constructor(model, parent) {
29 super(model, parent);
30 }
31 }
32 describe('DescriptorModel', () => {
33 let parent, child1, child2;
34 beforeEach(() => {
35 parent = new TestDescriptorModel({name: 'parent 1'});
36 child1 = new TestDescriptorModel({name: 'child 1'}, parent);
37 child2 = new TestDescriptorModel({name: 'child 2'}, parent);
38 });
39 it('creates a uid and stores it in the uiState field ":uid"', () => {
40 expect(child1.uid).toEqual(child1.model.uiState[':uid']);
41 });
42 describe('.constructor(model, parent)', () => {
43 it('creates child when parent is given on constructor', () => {
44 const child = new TestDescriptorModel({name: 'test1'}, parent);
45 expect(parent.children).toContain(child);
46 });
47 });
48 describe('.findChildByUid', () => {
49 it('finds an existing child', () => {
50 const result = parent.findChildByUid(child2.uid);
51 expect(result).toBe(child2);
52 });
53 });
54 });