3 * Copyright 2016 RIFT.IO Inc
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 * Created by onvelocity on 2/8/16.
21 /*global describe, beforeEach, it, expect, xit */
24 import _
from 'lodash'
25 import DescriptorModel
from 'libraries/model/DescriptorModel'
27 class TestDescriptorModel
extends DescriptorModel
{
28 constructor(model
, parent
) {
32 describe('DescriptorModel', () => {
33 let parent
, child1
, child2
;
35 parent
= new TestDescriptorModel({name
: 'parent 1'});
36 child1
= new TestDescriptorModel({name
: 'child 1'}, parent
);
37 child2
= new TestDescriptorModel({name
: 'child 2'}, parent
);
39 it('creates a uid and stores it in the uiState field ":uid"', () => {
40 expect(child1
.uid
).toEqual(child1
.model
.uiState
[':uid']);
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
);
48 describe('.findChildByUid', () => {
49 it('finds an existing child', () => {
50 const result
= parent
.findChildByUid(child2
.uid
);
51 expect(result
).toBe(child2
);