test: check XML import/export of style.baseStyleNames (#315)
Ensure that the array is correctly converted.development
parent
f2c2b4cbab
commit
c45b78a4da
|
@ -184,7 +184,12 @@ describe('export', () => {
|
||||||
v1.setStyle({ fillColor: 'green', strokeWidth: 4 });
|
v1.setStyle({ fillColor: 'green', strokeWidth: 4 });
|
||||||
v1.geometry = new Geometry(100, 100, 100, 80);
|
v1.geometry = new Geometry(100, 100, 100, 80);
|
||||||
const v2 = newVertex('v2', 'vertex 2');
|
const v2 = newVertex('v2', 'vertex 2');
|
||||||
v2.style = { bendable: false, rounded: true, fontColor: 'yellow' };
|
v2.style = {
|
||||||
|
bendable: false,
|
||||||
|
rounded: true,
|
||||||
|
fontColor: 'yellow',
|
||||||
|
baseStyleNames: ['style1', 'style2'],
|
||||||
|
};
|
||||||
model.add(parent, v2);
|
model.add(parent, v2);
|
||||||
|
|
||||||
const edge = newEdge('e1', 'edge');
|
const edge = newEdge('e1', 'edge');
|
||||||
|
@ -212,7 +217,12 @@ describe('export', () => {
|
||||||
<Object fillColor="green" strokeWidth="4" as="style" />
|
<Object fillColor="green" strokeWidth="4" as="style" />
|
||||||
</Cell>
|
</Cell>
|
||||||
<Cell id="v2" value="vertex 2" vertex="1" parent="1">
|
<Cell id="v2" value="vertex 2" vertex="1" parent="1">
|
||||||
<Object bendable="0" rounded="1" fontColor="yellow" as="style" />
|
<Object bendable="0" rounded="1" fontColor="yellow" as="style">
|
||||||
|
<Array as="baseStyleNames">
|
||||||
|
<add value="style1" />
|
||||||
|
<add value="style2" />
|
||||||
|
</Array>
|
||||||
|
</Object>
|
||||||
</Cell>
|
</Cell>
|
||||||
<Cell id="e1" value="edge" edge="1" parent="1" source="v1" target="v2">
|
<Cell id="e1" value="edge" edge="1" parent="1" source="v1" target="v2">
|
||||||
<Geometry as="geometry">
|
<Geometry as="geometry">
|
||||||
|
@ -245,4 +255,41 @@ describe('import after export', () => {
|
||||||
style: { fillColor: 'green', shape: 'triangle', strokeWidth: 4 },
|
style: { fillColor: 'green', shape: 'triangle', strokeWidth: 4 },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Cell with baseStyleNames style attribute', () => {
|
||||||
|
const model = new GraphDataModel();
|
||||||
|
new ModelXmlSerializer(model).import(
|
||||||
|
`<GraphDataModel>
|
||||||
|
<root>
|
||||||
|
<Cell id="0">
|
||||||
|
<Object as="style"/>
|
||||||
|
</Cell>
|
||||||
|
<Cell id="1" parent="0">
|
||||||
|
<Object as="style"/>
|
||||||
|
</Cell>
|
||||||
|
<Cell id="cell-1" vertex="1" parent="1">
|
||||||
|
<Object entryPerimeter="1" shadow="1" as="style">
|
||||||
|
<Array as="baseStyleNames">
|
||||||
|
<add value="style1" />
|
||||||
|
</Array>
|
||||||
|
</Object>
|
||||||
|
</Cell>
|
||||||
|
</root>
|
||||||
|
</GraphDataModel>`
|
||||||
|
);
|
||||||
|
|
||||||
|
const modelChecker = new ModelChecker(model);
|
||||||
|
modelChecker.checkRootCells();
|
||||||
|
modelChecker.checkCellsCount(3);
|
||||||
|
|
||||||
|
modelChecker.expectIsVertex(model.getCell('cell-1'), null, {
|
||||||
|
style: {
|
||||||
|
baseStyleNames: ['style1'],
|
||||||
|
// @ts-ignore FIX should be true
|
||||||
|
entryPerimeter: 1,
|
||||||
|
// @ts-ignore FIX should be true
|
||||||
|
shadow: 1,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -45,7 +45,11 @@ export class ModelChecker {
|
||||||
expect(cellIds).toHaveLength(count);
|
expect(cellIds).toHaveLength(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
expectIsVertex(cell: Cell | null, value: string, properties?: ExpectCellProperties) {
|
expectIsVertex(
|
||||||
|
cell: Cell | null,
|
||||||
|
value: string | null,
|
||||||
|
properties?: ExpectCellProperties
|
||||||
|
) {
|
||||||
this.checkCellBaseProperties(cell, value, properties);
|
this.checkCellBaseProperties(cell, value, properties);
|
||||||
if (!cell) return; // cannot occur, this is enforced by checkCellBaseProperties
|
if (!cell) return; // cannot occur, this is enforced by checkCellBaseProperties
|
||||||
expect(cell.edge).toEqual(false);
|
expect(cell.edge).toEqual(false);
|
||||||
|
|
Loading…
Reference in New Issue