diff --git a/src/style_manager/model/Layer.js b/src/style_manager/model/Layer.js index 548dcf5ca..eea723f70 100644 --- a/src/style_manager/model/Layer.js +++ b/src/style_manager/model/Layer.js @@ -1,16 +1,14 @@ define(['backbone'], function(Backbone) { - /** - * @class Layer - * */ + return Backbone.Model.extend({ - + defaults: { - name : '', - active : true, + name : '', + active : true, value : '', preview : false, } - - }); + + }); }); \ No newline at end of file diff --git a/src/style_manager/model/Layers.js b/src/style_manager/model/Layers.js index 1c49a30f3..977c577f7 100644 --- a/src/style_manager/model/Layers.js +++ b/src/style_manager/model/Layers.js @@ -1,11 +1,9 @@ -define([ 'backbone','./Layer'], - function (Backbone,Layer) { - /** - * @class Layers - * */ +define([ 'backbone', './Layer'], + function (Backbone, Layer) { + return Backbone.Collection.extend({ - + model: Layer, - + }); }); diff --git a/src/style_manager/model/Properties.js b/src/style_manager/model/Properties.js index 98d0e2f3f..6ea05cb17 100644 --- a/src/style_manager/model/Properties.js +++ b/src/style_manager/model/Properties.js @@ -1,11 +1,9 @@ -define([ 'backbone','./Property'], - function (Backbone,Property) { - /** - * @class Properties - * */ +define([ 'backbone', './Property'], + function (Backbone, Property) { + return Backbone.Collection.extend({ - + model: Property, - + }); }); diff --git a/src/style_manager/model/Property.js b/src/style_manager/model/Property.js index 1b00a7226..cf99e98c9 100644 --- a/src/style_manager/model/Property.js +++ b/src/style_manager/model/Property.js @@ -15,8 +15,8 @@ define(['backbone'], icon: '', preview: false, functionName: '', - properties: {}, - layers: {}, + properties: [], + layers: [], list: [], } diff --git a/test/specs/style_manager/main.js b/test/specs/style_manager/main.js index eb756f3c8..fa1f9d719 100644 --- a/test/specs/style_manager/main.js +++ b/test/specs/style_manager/main.js @@ -1,10 +1,12 @@ var modulePath = './../../../test/specs/style_manager'; define([ - 'StyleManager' + 'StyleManager', + modulePath + '/model/Models', ], function( - StyleManager + StyleManager, + Models ) { describe('StyleManager', function() { @@ -170,6 +172,8 @@ define([ }); + Models.run(); + }); }); diff --git a/test/specs/style_manager/model/Models.js b/test/specs/style_manager/model/Models.js new file mode 100644 index 000000000..c46855419 --- /dev/null +++ b/test/specs/style_manager/model/Models.js @@ -0,0 +1,152 @@ +var path = 'StyleManager/model/'; +define([path + 'Sector', + path + 'Sectors', + path + 'Property', + path + 'Properties', + path + 'Layer', + path + 'Layers'], + function(Sector, + Sectors, + Property, + Properties, + Layer, + Layers) { + + return { + run : function(){ + + describe('Sector', function() { + + var obj; + + beforeEach(function () { + obj = new Sector(); + }); + + afterEach(function () { + delete obj; + }); + + it('Has id property', function() { + obj.has('id').should.equal(true); + }); + + it('Has no properties', function() { + obj.get('properties').length.should.equal(0); + }); + + it('Init with properties', function() { + obj = new Sector({ + properties: [{}, {}] + }); + obj.get('properties').length.should.equal(2); + }); + + }); + + describe('Sectors', function() { + + var obj; + + beforeEach(function () { + obj = new Sectors(); + }); + + afterEach(function () { + delete obj; + }); + + it('Object exists', function() { + obj.should.be.ok; + }); + + }); + + describe('Property', function() { + + var obj; + + beforeEach(function () { + obj = new Property(); + }); + + afterEach(function () { + delete obj; + }); + + it('Has property field', function() { + obj.has('property').should.equal(true); + }); + + it('Has no properties', function() { + obj.get('properties').length.should.equal(0); + }); + + it('Has no layers', function() { + obj.get('layers').length.should.equal(0); + }); + + }); + + describe('Properties', function() { + + var obj; + + beforeEach(function () { + obj = new Properties(); + }); + + afterEach(function () { + delete obj; + }); + + it('Object exists', function() { + obj.should.be.ok; + }); + + }); + + describe('Layer', function() { + + var obj; + + beforeEach(function () { + obj = new Layer(); + }); + + afterEach(function () { + delete obj; + }); + + it('Has name property', function() { + obj.has('name').should.equal(true); + }); + + it('Is active', function() { + obj.get('active').should.equal(true); + }); + + }); + + describe('Layers', function() { + + var obj; + + beforeEach(function () { + obj = new Layers(); + }); + + afterEach(function () { + delete obj; + }); + + it('Object exists', function() { + obj.should.be.ok; + }); + + }); + + } + }; + +}); \ No newline at end of file