X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=skyquake%2Fplugins%2Fcomposer%2Ftest%2Fspec%2Flibraries%2FDescriptorModelSpec.js;fp=skyquake%2Fplugins%2Fcomposer%2Ftest%2Fspec%2Flibraries%2FDescriptorModelSpec.js;h=5388780a86987cf419fb41d219698e97cf5457b3;hb=e29efc315df33d546237e270470916e26df391d6;hp=0000000000000000000000000000000000000000;hpb=9c5e457509ba5a1822c316635c6308874e61b4b9;p=osm%2FUI.git diff --git a/skyquake/plugins/composer/test/spec/libraries/DescriptorModelSpec.js b/skyquake/plugins/composer/test/spec/libraries/DescriptorModelSpec.js new file mode 100644 index 000000000..5388780a8 --- /dev/null +++ b/skyquake/plugins/composer/test/spec/libraries/DescriptorModelSpec.js @@ -0,0 +1,54 @@ +/* + * + * Copyright 2016 RIFT.IO Inc + * + * Licensed under the Apache License, Version 2.0 (the "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. + * + */ +/** + * Created by onvelocity on 2/8/16. + */ +/*global describe, beforeEach, it, expect, xit */ + +'use strict'; +import _ from 'lodash' +import DescriptorModel from 'libraries/model/DescriptorModel' + +class TestDescriptorModel extends DescriptorModel { + constructor(model, parent) { + super(model, parent); + } +} +describe('DescriptorModel', () => { + let parent, child1, child2; + beforeEach(() => { + parent = new TestDescriptorModel({name: 'parent 1'}); + child1 = new TestDescriptorModel({name: 'child 1'}, parent); + child2 = new TestDescriptorModel({name: 'child 2'}, parent); + }); + it('creates a uid and stores it in the uiState field ":uid"', () => { + expect(child1.uid).toEqual(child1.model.uiState[':uid']); + }); + describe('.constructor(model, parent)', () => { + it('creates child when parent is given on constructor', () => { + const child = new TestDescriptorModel({name: 'test1'}, parent); + expect(parent.children).toContain(child); + }); + }); + describe('.findChildByUid', () => { + it('finds an existing child', () => { + const result = parent.findChildByUid(child2.uid); + expect(result).toBe(child2); + }); + }); +}); \ No newline at end of file