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 DescriptorModel
from 'libraries/model/DescriptorModel'
26 class TestDescriptorModel
extends DescriptorModel
{
27 constructor(model
, parent
) {
31 describe('DescriptorModel', () => {
32 let parent
, child1
, child2
;
34 parent
= new TestDescriptorModel({name
: 'parent 1'});
35 child1
= new TestDescriptorModel({name
: 'child 1'}, parent
);
36 child2
= new TestDescriptorModel({name
: 'child 2'}, parent
);
38 it('creates a uid and stores it in the uiState field ":uid"', () => {
39 expect(child1
.uid
).toEqual(child1
.model
.uiState
[':uid']);
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
);
47 describe('.findChildByUid', () => {
48 it('finds an existing child', () => {
49 const result
= parent
.findChildByUid(child2
.uid
);
50 expect(result
).toBe(child2
);