Browse Source

Update stack hasValue

up-style-manager
Artur Arseniev 4 years ago
parent
commit
1d6843daa0
  1. 10
      src/style_manager/model/PropertyStack.js
  2. 21
      test/specs/style_manager/model/Properties.js

10
src/style_manager/model/PropertyStack.js

@ -418,6 +418,16 @@ export default Property.extend({
return !detached ? style[property] : keys(validStyles).length ? validStyles : '';
},
/**
* Extended
* @private
*/
hasValue(opts = {}) {
const { noParent } = opts;
const parentValue = noParent && this.getParentTarget();
return this.getLayers().length > 0 && !parentValue;
},
/**
* This method allows to customize layers returned from the target
* @param {Object} target

21
test/specs/style_manager/model/Properties.js

@ -63,7 +63,7 @@ describe('StyleManager properties logic', () => {
expect(compTypePropInn).toBeTruthy();
});
test('Inner property has no value', () => {
test('Property has no value', () => {
expect(compTypeProp.hasValue()).toBe(false);
expect(compTypePropInn.hasValue()).toBe(false);
});
@ -88,7 +88,7 @@ describe('StyleManager properties logic', () => {
});
});
describe('Stack type (not detached)', () => {
describe('Stack type', () => {
const propTest = 'stack-prop';
const propATest = `${propTest}-a`;
const propBTest = `${propTest}-b`;
@ -131,6 +131,10 @@ describe('StyleManager properties logic', () => {
expect(compTypeProp.getLayers().length).toBe(2);
});
test('Property has no value', () => {
expect(compTypeProp.hasValue()).toBe(true);
});
test('Has no selected layer', () => {
expect(compTypeProp.getSelectedLayer()).toBe(null);
});
@ -285,6 +289,19 @@ describe('StyleManager properties logic', () => {
});
});
test.skip('On clear removes all values', () => {
compTypeProp.clear();
expect(compTypeProp.hasValue()).toBe(false);
expect(compTypeProp.getLayers().length).toBe(0);
expect(rule1.getStyle()).toEqual({
__p: false,
[propTest]: '',
[propATest]: '',
[propBTest]: '',
[propCTest]: '',
});
});
test('Adding new layer, updates the rule', () => {
compTypeProp.addLayer(
{

Loading…
Cancel
Save