|
|
|
@ -1,9 +1,6 @@ |
|
|
|
import Sector from 'style_manager/model/Sector'; |
|
|
|
import Property from 'style_manager/model/Property'; |
|
|
|
import PropertyNumber from 'style_manager/model/PropertyNumber'; |
|
|
|
import Properties from 'style_manager/model/Properties'; |
|
|
|
import Layer from 'style_manager/model/Layer'; |
|
|
|
import Layers from 'style_manager/model/Layers'; |
|
|
|
import Editor from 'editor/model/Editor'; |
|
|
|
|
|
|
|
describe('Sector', () => { |
|
|
|
@ -198,119 +195,3 @@ describe('PropertyNumber', () => { |
|
|
|
expect(obj.parseValue('95px')).toEqual({ value: 95, unit: 'px' }); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
describe('Properties', () => { |
|
|
|
var obj; |
|
|
|
|
|
|
|
beforeEach(() => { |
|
|
|
obj = new Properties(); |
|
|
|
}); |
|
|
|
|
|
|
|
afterEach(() => { |
|
|
|
obj = null; |
|
|
|
}); |
|
|
|
|
|
|
|
test('Object exists', () => { |
|
|
|
expect(obj).toBeTruthy(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
describe('Layer', () => { |
|
|
|
var obj; |
|
|
|
var properties = [ |
|
|
|
{ value: 'val1', property: 'prop1' }, |
|
|
|
{ value: 'val2', property: 'prop2' }, |
|
|
|
{ value: 'val3', property: 'prop3', functionName: 'test' }, |
|
|
|
]; |
|
|
|
|
|
|
|
beforeEach(() => { |
|
|
|
obj = new Layer(); |
|
|
|
}); |
|
|
|
|
|
|
|
afterEach(() => { |
|
|
|
obj = null; |
|
|
|
}); |
|
|
|
|
|
|
|
test('Has index property', () => { |
|
|
|
expect(obj.has('index')).toEqual(true); |
|
|
|
}); |
|
|
|
|
|
|
|
test('Is not active', () => { |
|
|
|
expect(obj.get('active')).toEqual(false); |
|
|
|
}); |
|
|
|
|
|
|
|
test('Has no properties', () => { |
|
|
|
expect(obj.get('properties').length).toEqual(0); |
|
|
|
}); |
|
|
|
|
|
|
|
test('Get correct values from properties', () => { |
|
|
|
obj = new Layer({ |
|
|
|
properties, |
|
|
|
}); |
|
|
|
expect(obj.getFullValue()).toEqual('val1 val2 test(val3)'); |
|
|
|
}); |
|
|
|
|
|
|
|
test('Get correct value from properties', () => { |
|
|
|
obj = new Layer({ properties }); |
|
|
|
expect(obj.getPropertyValue()).toEqual(''); |
|
|
|
expect(obj.getPropertyValue('no-prop')).toEqual(''); |
|
|
|
expect(obj.getPropertyValue('prop3')).toEqual('test(val3)'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
describe('Layers', () => { |
|
|
|
var obj; |
|
|
|
var properties = [ |
|
|
|
{ value: 'val1', property: 'prop1' }, |
|
|
|
{ value: 'val2', property: 'prop2' }, |
|
|
|
{ value: 'val3', property: 'prop3', functionName: 'test' }, |
|
|
|
]; |
|
|
|
|
|
|
|
beforeEach(() => { |
|
|
|
obj = new Layers(); |
|
|
|
}); |
|
|
|
|
|
|
|
afterEach(() => { |
|
|
|
obj = null; |
|
|
|
}); |
|
|
|
|
|
|
|
test('Object exists', () => { |
|
|
|
expect(obj).toBeTruthy(); |
|
|
|
}); |
|
|
|
|
|
|
|
test('Init index on add', () => { |
|
|
|
var model = obj.add({}); |
|
|
|
expect(model.get('index')).toEqual(1); |
|
|
|
}); |
|
|
|
|
|
|
|
test('Increment index', () => { |
|
|
|
var model = obj.add({}); |
|
|
|
var model2 = obj.add({}); |
|
|
|
expect(model2.get('index')).toEqual(2); |
|
|
|
}); |
|
|
|
|
|
|
|
test('Cache index', () => { |
|
|
|
var model = obj.add({}); |
|
|
|
var model2 = obj.add({}); |
|
|
|
obj.remove(model2); |
|
|
|
var model3 = obj.add({}); |
|
|
|
expect(model3.get('index')).toEqual(3); |
|
|
|
}); |
|
|
|
|
|
|
|
test('Reset index on reset', () => { |
|
|
|
var model = obj.add({}); |
|
|
|
var model2 = obj.add({}); |
|
|
|
obj.reset(); |
|
|
|
expect(obj.idx).toEqual(1); |
|
|
|
}); |
|
|
|
|
|
|
|
test('getFullValue from layers', () => { |
|
|
|
obj = new Layers([{ properties }, { properties }, { properties }]); |
|
|
|
expect(obj.getFullValue()).toEqual('val1 val2 test(val3), val1 val2 test(val3), val1 val2 test(val3)'); |
|
|
|
}); |
|
|
|
|
|
|
|
test('getPropertyValues from layers', () => { |
|
|
|
obj = new Layers([{ properties }, { properties }, { properties }]); |
|
|
|
expect(obj.getPropertyValues('prop3')).toEqual('test(val3), test(val3), test(val3)'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|