Browse Source

Test custom fromStyle

up-style-manager
Artur Arseniev 4 years ago
parent
commit
5ce84d4876
  1. 6
      src/style_manager/model/PropertyStack.js
  2. 19
      test/specs/style_manager/model/Properties.js

6
src/style_manager/model/PropertyStack.js

@ -168,12 +168,12 @@ export default Property.extend({
if (!hasProps) {
return [];
} else {
const sep = this.getLayerSeparator();
const sepParts = this.getPartsSeparator();
const fromStyle = this.get('fromStyle');
let result = fromStyle ? fromStyle(style, { property: this }) : [];
let result = fromStyle ? fromStyle(style, { property: this, separatorLayers: sep }) : [];
if (!fromStyle) {
const sep = this.getLayerSeparator();
const sepParts = this.getPartsSeparator();
// Get layers from the main property
const layers = splitStyleName(style, name, sep)
.map(value => value.split(sepParts))

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

@ -159,6 +159,25 @@ describe('StyleManager properties logic', () => {
]);
});
test('Custom fromStyle', () => {
compTypeProp.set('fromStyle', (style, { separatorLayers }) => {
const layerValues = style[propTest].split(separatorLayers);
return layerValues.map(value => ({ value }));
});
expect(
compTypeProp.__getLayersFromStyle({
[propTest]: 'rgba(valueA-1, valueB-1), rgba(valueA-2, valueB-2)',
})
).toEqual([
{
value: 'rgba(valueA-1, valueB-1)',
},
{
value: 'rgba(valueA-2, valueB-2)',
},
]);
});
test('Layers has the right values', () => {
expect(compTypeProp.getLayer(0).getValues()).toEqual({
[propATest]: 'valueA-1',

Loading…
Cancel
Save