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`] = `
[
{
"height": 200,
"id": "rect-1",
"type": "rectangle",
"width": 100,
"x": 300,
"y": 100,
},
{
"height": 200,
"id": "rect-1_copy",
"type": "rectangle",
"width": 100,
"x": 100,
"y": 200,
},
]
{
"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": 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`] = `
@ -954,95 +993,261 @@ exports[`Test Transform > should transform linear elements 4`] = `
`;
exports[`Test Transform > should transform regular shapes 1`] = `
[
{
"height": 100,
"id": "id0",
"type": "rectangle",
"width": 100,
"x": 100,
"y": 100,
},
{
"height": 100,
"id": "id1",
"type": "ellipse",
"width": 100,
"x": 100,
"y": 250,
},
{
"height": 100,
"id": "id2",
"type": "diamond",
"width": 100,
"x": 100,
"y": 400,
},
{
"backgroundColor": "#c0eb75",
"height": 100,
"id": "id3",
"strokeWidth": 2,
"type": "rectangle",
"width": 200,
"x": 300,
"y": 100,
},
{
"backgroundColor": "#ffc9c9",
"fillStyle": "solid",
"height": 100,
"id": "id4",
"strokeStyle": "dotted",
"strokeWidth": 2,
"type": "ellipse",
"width": 200,
"x": 300,
"y": 250,
},
{
"backgroundColor": "#a5d8ff",
"fillStyle": "cross-hatch",
"height": 100,
"id": "id5",
"strokeColor": "#1971c2",
"strokeStyle": "dashed",
"strokeWidth": 2,
"type": "diamond",
"width": 200,
"x": 300,
"y": 400,
},
]
{
"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": "rectangle",
"updated": 1,
"version": 1,
"versionNonce": Any<Number>,
"width": 100,
"x": 100,
"y": 100,
}
`;
exports[`Test Transform > should transform regular shapes 2`] = `
{
"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": "ellipse",
"updated": 1,
"version": 1,
"versionNonce": Any<Number>,
"width": 100,
"x": 100,
"y": 250,
}
`;
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`] = `
[
{
"fontFamily": 1,
"fontSize": 20,
"height": 25,
"id": "id6",
"text": "HELLO WORLD!",
"type": "text",
"width": 120,
"x": 100,
"y": 100,
},
{
"fontFamily": 1,
"fontSize": 20,
"height": 25,
"id": "id7",
"strokeColor": "#5f3dc4",
"text": "STYLED HELLO WORLD!",
"type": "text",
"width": 190,
"x": 100,
"y": 150,
},
]
{
"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": "HELLO WORLD!",
"roughness": 1,
"roundness": null,
"seed": Any<Number>,
"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`] = `

View file

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