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,
"backgroundColor": "transparent",
"boundElements": null,
"fillStyle": "hachure",
"frameId": null,
"groupIds": [],
"height": 200, "height": 200,
"id": "rect-1", "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", "type": "rectangle",
"updated": 1,
"version": 1,
"versionNonce": Any<Number>,
"width": 100, "width": 100,
"x": 300, "x": 300,
"y": 100, "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, "height": 200,
"id": "rect-1_copy", "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", "type": "rectangle",
"updated": 1,
"version": 1,
"versionNonce": Any<Number>,
"width": 100, "width": 100,
"x": 100, "x": 100,
"y": 200, "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,
"backgroundColor": "transparent",
"boundElements": null,
"fillStyle": "hachure",
"frameId": null,
"groupIds": [],
"height": 100, "height": 100,
"id": "id0", "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", "type": "rectangle",
"updated": 1,
"version": 1,
"versionNonce": Any<Number>,
"width": 100, "width": 100,
"x": 100, "x": 100,
"y": 100, "y": 100,
}, }
`;
exports[`Test Transform > should transform regular shapes 2`] = `
{ {
"angle": 0,
"backgroundColor": "transparent",
"boundElements": null,
"fillStyle": "hachure",
"frameId": null,
"groupIds": [],
"height": 100, "height": 100,
"id": "id1", "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": "ellipse", "type": "ellipse",
"updated": 1,
"version": 1,
"versionNonce": Any<Number>,
"width": 100, "width": 100,
"x": 100, "x": 100,
"y": 250, "y": 250,
}, }
`;
exports[`Test Transform > should transform regular shapes 3`] = `
{ {
"angle": 0,
"backgroundColor": "transparent",
"boundElements": null,
"fillStyle": "hachure",
"frameId": null,
"groupIds": [],
"height": 100, "height": 100,
"id": "id2", "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", "type": "diamond",
"updated": 1,
"version": 1,
"versionNonce": Any<Number>,
"width": 100, "width": 100,
"x": 100, "x": 100,
"y": 400, "y": 400,
}, }
`;
exports[`Test Transform > should transform regular shapes 4`] = `
{ {
"angle": 0,
"backgroundColor": "#c0eb75", "backgroundColor": "#c0eb75",
"boundElements": null,
"fillStyle": "hachure",
"frameId": null,
"groupIds": [],
"height": 100, "height": 100,
"id": "id3", "id": Any<String>,
"isDeleted": false,
"link": null,
"locked": false,
"opacity": 100,
"roughness": 1,
"roundness": null,
"seed": Any<Number>,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 2, "strokeWidth": 2,
"type": "rectangle", "type": "rectangle",
"updated": 1,
"version": 1,
"versionNonce": Any<Number>,
"width": 200, "width": 200,
"x": 300, "x": 300,
"y": 100, "y": 100,
}, }
`;
exports[`Test Transform > should transform regular shapes 5`] = `
{ {
"angle": 0,
"backgroundColor": "#ffc9c9", "backgroundColor": "#ffc9c9",
"boundElements": null,
"fillStyle": "solid", "fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 100, "height": 100,
"id": "id4", "id": Any<String>,
"isDeleted": false,
"link": null,
"locked": false,
"opacity": 100,
"roughness": 1,
"roundness": null,
"seed": Any<Number>,
"strokeColor": "#1e1e1e",
"strokeStyle": "dotted", "strokeStyle": "dotted",
"strokeWidth": 2, "strokeWidth": 2,
"type": "ellipse", "type": "ellipse",
"updated": 1,
"version": 1,
"versionNonce": Any<Number>,
"width": 200, "width": 200,
"x": 300, "x": 300,
"y": 250, "y": 250,
}, }
`;
exports[`Test Transform > should transform regular shapes 6`] = `
{ {
"angle": 0,
"backgroundColor": "#a5d8ff", "backgroundColor": "#a5d8ff",
"boundElements": null,
"fillStyle": "cross-hatch", "fillStyle": "cross-hatch",
"frameId": null,
"groupIds": [],
"height": 100, "height": 100,
"id": "id5", "id": Any<String>,
"isDeleted": false,
"link": null,
"locked": false,
"opacity": 100,
"roughness": 1,
"roundness": null,
"seed": Any<Number>,
"strokeColor": "#1971c2", "strokeColor": "#1971c2",
"strokeStyle": "dashed", "strokeStyle": "dashed",
"strokeWidth": 2, "strokeWidth": 2,
"type": "diamond", "type": "diamond",
"updated": 1,
"version": 1,
"versionNonce": Any<Number>,
"width": 200, "width": 200,
"x": 300, "x": 300,
"y": 400, "y": 400,
}, }
]
`; `;
exports[`Test Transform > should transform text element 1`] = ` exports[`Test Transform > should transform text element 1`] = `
[
{ {
"angle": 0,
"backgroundColor": "transparent",
"baseline": 0,
"boundElements": null,
"containerId": null,
"fillStyle": "hachure",
"fontFamily": 1, "fontFamily": 1,
"fontSize": 20, "fontSize": 20,
"frameId": null,
"groupIds": [],
"height": 25, "height": 25,
"id": "id6", "id": Any<String>,
"isDeleted": false,
"lineHeight": 1.25,
"link": null,
"locked": false,
"opacity": 100,
"originalText": "HELLO WORLD!",
"roughness": 1,
"roundness": null,
"seed": Any<Number>,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"text": "HELLO WORLD!", "text": "HELLO WORLD!",
"textAlign": "left",
"type": "text", "type": "text",
"updated": 1,
"version": 1,
"versionNonce": Any<Number>,
"verticalAlign": "top",
"width": 120, "width": 120,
"x": 100, "x": 100,
"y": 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, "fontFamily": 1,
"fontSize": 20, "fontSize": 20,
"frameId": null,
"groupIds": [],
"height": 25, "height": 25,
"id": "id7", "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", "strokeColor": "#5f3dc4",
"strokeStyle": "solid",
"strokeWidth": 1,
"text": "STYLED HELLO WORLD!", "text": "STYLED HELLO WORLD!",
"textAlign": "left",
"type": "text", "type": "text",
"updated": 1,
"version": 1,
"versionNonce": Any<Number>,
"verticalAlign": "top",
"width": 190, "width": 190,
"x": 100, "x": 100,
"y": 150, "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) => {
).toMatchSnapshot(); expect(ele).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) => {
).toMatchSnapshot(); expect(ele).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) => {
).toMatchSnapshot(); expect(ele).toMatchSnapshot({
seed: expect.any(Number),
versionNonce: expect.any(Number),
id: expect.any(String),
});
});
}); });
}); });