fix snaps

This commit is contained in:
Aakansha Doshi 2023-08-03 12:14:21 +05:30
parent e49c94f22f
commit 8aed24312f
2 changed files with 336 additions and 119 deletions

View file

@ -753,24 +753,63 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to text when
`; `;
exports[`Test Transform > should generate new ids if multiple elements contain same ids 1`] = ` exports[`Test Transform > should generate new ids if multiple elements contain same ids 1`] = `
[ {
{ "angle": 0,
"height": 200, "backgroundColor": "transparent",
"id": "rect-1", "boundElements": null,
"type": "rectangle", "fillStyle": "hachure",
"width": 100, "frameId": null,
"x": 300, "groupIds": [],
"y": 100, "height": 200,
}, "id": Any<String>,
{ "isDeleted": false,
"height": 200, "link": null,
"id": "rect-1_copy", "locked": false,
"type": "rectangle", "opacity": 100,
"width": 100, "roughness": 1,
"x": 100, "roundness": null,
"y": 200, "seed": Any<Number>,
}, "strokeColor": "#1e1e1e",
] "strokeStyle": "solid",
"strokeWidth": 1,
"type": "rectangle",
"updated": 1,
"version": 1,
"versionNonce": Any<Number>,
"width": 100,
"x": 300,
"y": 100,
}
`;
exports[`Test Transform > should generate new ids if multiple elements contain same ids 2`] = `
{
"angle": 0,
"backgroundColor": "transparent",
"boundElements": null,
"fillStyle": "hachure",
"frameId": null,
"groupIds": [],
"height": 200,
"id": Any<String>,
"isDeleted": false,
"link": null,
"locked": false,
"opacity": 100,
"roughness": 1,
"roundness": null,
"seed": Any<Number>,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "rectangle",
"updated": 1,
"version": 1,
"versionNonce": Any<Number>,
"width": 100,
"x": 100,
"y": 200,
}
`; `;
exports[`Test Transform > should transform linear elements 1`] = ` exports[`Test Transform > should transform linear elements 1`] = `
@ -954,95 +993,261 @@ exports[`Test Transform > should transform linear elements 4`] = `
`; `;
exports[`Test Transform > should transform regular shapes 1`] = ` exports[`Test Transform > should transform regular shapes 1`] = `
[ {
{ "angle": 0,
"height": 100, "backgroundColor": "transparent",
"id": "id0", "boundElements": null,
"type": "rectangle", "fillStyle": "hachure",
"width": 100, "frameId": null,
"x": 100, "groupIds": [],
"y": 100, "height": 100,
}, "id": Any<String>,
{ "isDeleted": false,
"height": 100, "link": null,
"id": "id1", "locked": false,
"type": "ellipse", "opacity": 100,
"width": 100, "roughness": 1,
"x": 100, "roundness": null,
"y": 250, "seed": Any<Number>,
}, "strokeColor": "#1e1e1e",
{ "strokeStyle": "solid",
"height": 100, "strokeWidth": 1,
"id": "id2", "type": "rectangle",
"type": "diamond", "updated": 1,
"width": 100, "version": 1,
"x": 100, "versionNonce": Any<Number>,
"y": 400, "width": 100,
}, "x": 100,
{ "y": 100,
"backgroundColor": "#c0eb75", }
"height": 100, `;
"id": "id3",
"strokeWidth": 2, exports[`Test Transform > should transform regular shapes 2`] = `
"type": "rectangle", {
"width": 200, "angle": 0,
"x": 300, "backgroundColor": "transparent",
"y": 100, "boundElements": null,
}, "fillStyle": "hachure",
{ "frameId": null,
"backgroundColor": "#ffc9c9", "groupIds": [],
"fillStyle": "solid", "height": 100,
"height": 100, "id": Any<String>,
"id": "id4", "isDeleted": false,
"strokeStyle": "dotted", "link": null,
"strokeWidth": 2, "locked": false,
"type": "ellipse", "opacity": 100,
"width": 200, "roughness": 1,
"x": 300, "roundness": null,
"y": 250, "seed": Any<Number>,
}, "strokeColor": "#1e1e1e",
{ "strokeStyle": "solid",
"backgroundColor": "#a5d8ff", "strokeWidth": 1,
"fillStyle": "cross-hatch", "type": "ellipse",
"height": 100, "updated": 1,
"id": "id5", "version": 1,
"strokeColor": "#1971c2", "versionNonce": Any<Number>,
"strokeStyle": "dashed", "width": 100,
"strokeWidth": 2, "x": 100,
"type": "diamond", "y": 250,
"width": 200, }
"x": 300, `;
"y": 400,
}, exports[`Test Transform > should transform regular shapes 3`] = `
] {
"angle": 0,
"backgroundColor": "transparent",
"boundElements": null,
"fillStyle": "hachure",
"frameId": null,
"groupIds": [],
"height": 100,
"id": Any<String>,
"isDeleted": false,
"link": null,
"locked": false,
"opacity": 100,
"roughness": 1,
"roundness": null,
"seed": Any<Number>,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "diamond",
"updated": 1,
"version": 1,
"versionNonce": Any<Number>,
"width": 100,
"x": 100,
"y": 400,
}
`;
exports[`Test Transform > should transform regular shapes 4`] = `
{
"angle": 0,
"backgroundColor": "#c0eb75",
"boundElements": null,
"fillStyle": "hachure",
"frameId": null,
"groupIds": [],
"height": 100,
"id": Any<String>,
"isDeleted": false,
"link": null,
"locked": false,
"opacity": 100,
"roughness": 1,
"roundness": null,
"seed": Any<Number>,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 2,
"type": "rectangle",
"updated": 1,
"version": 1,
"versionNonce": Any<Number>,
"width": 200,
"x": 300,
"y": 100,
}
`;
exports[`Test Transform > should transform regular shapes 5`] = `
{
"angle": 0,
"backgroundColor": "#ffc9c9",
"boundElements": null,
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 100,
"id": Any<String>,
"isDeleted": false,
"link": null,
"locked": false,
"opacity": 100,
"roughness": 1,
"roundness": null,
"seed": Any<Number>,
"strokeColor": "#1e1e1e",
"strokeStyle": "dotted",
"strokeWidth": 2,
"type": "ellipse",
"updated": 1,
"version": 1,
"versionNonce": Any<Number>,
"width": 200,
"x": 300,
"y": 250,
}
`;
exports[`Test Transform > should transform regular shapes 6`] = `
{
"angle": 0,
"backgroundColor": "#a5d8ff",
"boundElements": null,
"fillStyle": "cross-hatch",
"frameId": null,
"groupIds": [],
"height": 100,
"id": Any<String>,
"isDeleted": false,
"link": null,
"locked": false,
"opacity": 100,
"roughness": 1,
"roundness": null,
"seed": Any<Number>,
"strokeColor": "#1971c2",
"strokeStyle": "dashed",
"strokeWidth": 2,
"type": "diamond",
"updated": 1,
"version": 1,
"versionNonce": Any<Number>,
"width": 200,
"x": 300,
"y": 400,
}
`; `;
exports[`Test Transform > should transform text element 1`] = ` exports[`Test Transform > should transform text element 1`] = `
[ {
{ "angle": 0,
"fontFamily": 1, "backgroundColor": "transparent",
"fontSize": 20, "baseline": 0,
"height": 25, "boundElements": null,
"id": "id6", "containerId": null,
"text": "HELLO WORLD!", "fillStyle": "hachure",
"type": "text", "fontFamily": 1,
"width": 120, "fontSize": 20,
"x": 100, "frameId": null,
"y": 100, "groupIds": [],
}, "height": 25,
{ "id": Any<String>,
"fontFamily": 1, "isDeleted": false,
"fontSize": 20, "lineHeight": 1.25,
"height": 25, "link": null,
"id": "id7", "locked": false,
"strokeColor": "#5f3dc4", "opacity": 100,
"text": "STYLED HELLO WORLD!", "originalText": "HELLO WORLD!",
"type": "text", "roughness": 1,
"width": 190, "roundness": null,
"x": 100, "seed": Any<Number>,
"y": 150, "strokeColor": "#1e1e1e",
}, "strokeStyle": "solid",
] "strokeWidth": 1,
"text": "HELLO WORLD!",
"textAlign": "left",
"type": "text",
"updated": 1,
"version": 1,
"versionNonce": Any<Number>,
"verticalAlign": "top",
"width": 120,
"x": 100,
"y": 100,
}
`;
exports[`Test Transform > should transform text element 2`] = `
{
"angle": 0,
"backgroundColor": "transparent",
"baseline": 0,
"boundElements": null,
"containerId": null,
"fillStyle": "hachure",
"fontFamily": 1,
"fontSize": 20,
"frameId": null,
"groupIds": [],
"height": 25,
"id": Any<String>,
"isDeleted": false,
"lineHeight": 1.25,
"link": null,
"locked": false,
"opacity": 100,
"originalText": "STYLED HELLO WORLD!",
"roughness": 1,
"roundness": null,
"seed": Any<Number>,
"strokeColor": "#5f3dc4",
"strokeStyle": "solid",
"strokeWidth": 1,
"text": "STYLED HELLO WORLD!",
"textAlign": "left",
"type": "text",
"updated": 1,
"version": 1,
"versionNonce": Any<Number>,
"verticalAlign": "top",
"width": 190,
"x": 100,
"y": 150,
}
`; `;
exports[`Test Transform > should transform to labelled arrows when label provided for arrows 1`] = ` exports[`Test Transform > should transform to labelled arrows when label provided for arrows 1`] = `

View file

@ -55,11 +55,15 @@ describe("Test Transform", () => {
}, },
]; ];
expect( convertToExcalidrawElements(
convertToExcalidrawElements( elements as ExcalidrawProgrammaticAPI["elements"],
elements as ExcalidrawProgrammaticAPI["elements"], ).forEach((ele) => {
), expect(ele).toMatchSnapshot({
).toMatchSnapshot(); seed: expect.any(Number),
versionNonce: expect.any(Number),
id: expect.any(String),
});
});
}); });
it("should transform text element", () => { it("should transform text element", () => {
@ -79,11 +83,15 @@ describe("Test Transform", () => {
strokeColor: "#5f3dc4", strokeColor: "#5f3dc4",
}, },
]; ];
expect( convertToExcalidrawElements(
convertToExcalidrawElements( elements as ExcalidrawProgrammaticAPI["elements"],
elements as ExcalidrawProgrammaticAPI["elements"], ).forEach((ele) => {
), expect(ele).toMatchSnapshot({
).toMatchSnapshot(); seed: expect.any(Number),
versionNonce: expect.any(Number),
id: expect.any(String),
});
});
}); });
it("should transform linear elements", () => { it("should transform linear elements", () => {
@ -627,10 +635,14 @@ describe("Test Transform", () => {
height: 200, height: 200,
}, },
]; ];
expect( convertToExcalidrawElements(
convertToExcalidrawElements( elements as ExcalidrawProgrammaticAPI["elements"],
elements as ExcalidrawProgrammaticAPI["elements"], ).forEach((ele) => {
), expect(ele).toMatchSnapshot({
).toMatchSnapshot(); seed: expect.any(Number),
versionNonce: expect.any(Number),
id: expect.any(String),
});
});
}); });
}); });