mirror of https://github.com/artf/grapesjs.git
6 changed files with 176 additions and 26 deletions
@ -1,16 +1,14 @@ |
|||||
define(['backbone'], |
define(['backbone'], |
||||
function(Backbone) { |
function(Backbone) { |
||||
/** |
|
||||
* @class Layer |
|
||||
* */ |
|
||||
return Backbone.Model.extend({ |
return Backbone.Model.extend({ |
||||
|
|
||||
defaults: { |
defaults: { |
||||
name : '', |
name : '', |
||||
active : true, |
active : true, |
||||
value : '', |
value : '', |
||||
preview : false, |
preview : false, |
||||
} |
} |
||||
|
|
||||
}); |
}); |
||||
}); |
}); |
||||
@ -1,11 +1,9 @@ |
|||||
define([ 'backbone','./Layer'], |
define([ 'backbone', './Layer'], |
||||
function (Backbone,Layer) { |
function (Backbone, Layer) { |
||||
/** |
|
||||
* @class Layers |
|
||||
* */ |
|
||||
return Backbone.Collection.extend({ |
return Backbone.Collection.extend({ |
||||
|
|
||||
model: Layer, |
model: Layer, |
||||
|
|
||||
}); |
}); |
||||
}); |
}); |
||||
|
|||||
@ -1,11 +1,9 @@ |
|||||
define([ 'backbone','./Property'], |
define([ 'backbone', './Property'], |
||||
function (Backbone,Property) { |
function (Backbone, Property) { |
||||
/** |
|
||||
* @class Properties |
|
||||
* */ |
|
||||
return Backbone.Collection.extend({ |
return Backbone.Collection.extend({ |
||||
|
|
||||
model: Property, |
model: Property, |
||||
|
|
||||
}); |
}); |
||||
}); |
}); |
||||
|
|||||
@ -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; |
||||
|
}); |
||||
|
|
||||
|
}); |
||||
|
|
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
}); |
||||
Loading…
Reference in new issue