Browse Source

Test more composite type

up-style-manager
Artur Arseniev 5 years ago
parent
commit
ff7569a893
  1. 5
      src/style_manager/index.js
  2. 4
      src/style_manager/model/PropertyStack.js
  3. 47
      test/specs/style_manager/model/Properties.js

5
src/style_manager/index.js

@ -617,7 +617,10 @@ export default () => {
prop.__setParentTarget(parentTarget);
prop.__getFullValue() !== newValue && prop.upValue(newValue, { ...opts, __up: true });
isStack && prop.__setLayers(newLayers || []);
isComposite && prop.__setProperties(newProps || {});
if (isComposite) {
prop.__setProperties(newProps || {});
prop.getProperties().map(pr => pr.__setParentTarget(parentTarget));
}
},
destroy() {

4
src/style_manager/model/PropertyStack.js

@ -163,10 +163,6 @@ export default Property.extend({
return isArray(result) ? result : [result];
},
hasValue(opts) {
return PropertyBase.prototype.hasValue.call(this, opts);
},
/**
* Add new layer to the stack
* @param {Object} [props={}] Layer props

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

@ -184,6 +184,53 @@ describe('StyleManager properties logic', () => {
});
});
test('On clear removes all values', () => {
rule1.setStyle({ padding: '1px 2px 3px 4px' });
obj.__upSel();
expect(compTypeProp.hasValue()).toBe(true);
compTypeProp.clear();
expect(compTypeProp.hasValue()).toBe(false);
expect(rule1.getStyle()).toEqual({
__p: false,
[propTest]: '',
[propATest]: '',
[propBTest]: '',
[propCTest]: '',
[propDTest]: '',
});
});
test('Get the values from parent style', () => {
rule1.setStyle({
padding: '11px 22px',
'padding-left': '44px',
});
const rule2 = cssc.addRules(`
@media (max-width: 992px) {
.cls { color: red; }
}
`)[0];
dv.select('tablet');
obj.__upSel();
expect(obj.getLastSelected()).toBe(rule2);
expect(obj.getSelectedParents()).toEqual([rule1]);
expect(compTypeProp.hasValue()).toBe(true);
expect(compTypeProp.hasValue({ noParent: true })).toBe(false);
[
[propATest, '11px'],
[propBTest, '22px'],
[propCTest, '11px'],
[propDTest, '44px'],
].forEach(item => {
const prop = compTypeProp.getProperty(item[0]);
expect(prop.hasValue()).toBe(true);
expect(prop.hasValue({ noParent: true })).toBe(false);
expect(prop.getFullValue()).toBe(item[1]);
});
});
test('getStyleFromProps with custom toStyle', () => {
rule1.setStyle({ padding: '1px 2px 3px 4px' });
obj.__upSel();

Loading…
Cancel
Save