test: add unit tests for restore.ts file (#3679)
* Add unit tests for restore.ts file * Improving describe blocks in restore tests * Move restore.tests.ts folder and remove depedency of UI in the tests * Adding snapshots to restore.ts tests * Using snapshot in freedraw test * Updating description of test for line and draw elements * Updating description of test for arrow element * Improving restoreAppState tests * specs cleanup * fix * fix Co-authored-by: Aakansha Doshi <aakansha1216@gmail.com>
This commit is contained in:
308
src/tests/data/__snapshots__/restore.test.ts.snap
Normal file
308
src/tests/data/__snapshots__/restore.test.ts.snap
Normal file
@ -0,0 +1,308 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`restoreElements should restore arrow element correctly 1`] = `
|
||||
Object {
|
||||
"angle": 0,
|
||||
"backgroundColor": "transparent",
|
||||
"boundElementIds": Array [],
|
||||
"endArrowhead": null,
|
||||
"endBinding": null,
|
||||
"fillStyle": "hachure",
|
||||
"groupIds": Array [],
|
||||
"height": 0,
|
||||
"id": "id-arrow01",
|
||||
"isDeleted": false,
|
||||
"lastCommittedPoint": null,
|
||||
"opacity": 100,
|
||||
"points": Array [
|
||||
Array [
|
||||
0,
|
||||
0,
|
||||
],
|
||||
Array [
|
||||
0,
|
||||
0,
|
||||
],
|
||||
],
|
||||
"roughness": 1,
|
||||
"seed": Any<Number>,
|
||||
"startArrowhead": null,
|
||||
"startBinding": null,
|
||||
"strokeColor": "#000000",
|
||||
"strokeSharpness": "sharp",
|
||||
"strokeStyle": "solid",
|
||||
"strokeWidth": 1,
|
||||
"type": "arrow",
|
||||
"version": 1,
|
||||
"versionNonce": 0,
|
||||
"width": 0,
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`restoreElements should restore correctly with rectangle, ellipse and diamond elements 1`] = `
|
||||
Object {
|
||||
"angle": 0,
|
||||
"backgroundColor": "blue",
|
||||
"boundElementIds": Array [],
|
||||
"fillStyle": "cross-hatch",
|
||||
"groupIds": Array [
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
],
|
||||
"height": 200,
|
||||
"id": "1",
|
||||
"isDeleted": false,
|
||||
"opacity": 10,
|
||||
"roughness": 2,
|
||||
"seed": Any<Number>,
|
||||
"strokeColor": "red",
|
||||
"strokeSharpness": "round",
|
||||
"strokeStyle": "dashed",
|
||||
"strokeWidth": 2,
|
||||
"type": "rectangle",
|
||||
"version": 1,
|
||||
"versionNonce": 0,
|
||||
"width": 100,
|
||||
"x": 10,
|
||||
"y": 20,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`restoreElements should restore correctly with rectangle, ellipse and diamond elements 2`] = `
|
||||
Object {
|
||||
"angle": 0,
|
||||
"backgroundColor": "blue",
|
||||
"boundElementIds": Array [],
|
||||
"fillStyle": "cross-hatch",
|
||||
"groupIds": Array [
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
],
|
||||
"height": 200,
|
||||
"id": "2",
|
||||
"isDeleted": false,
|
||||
"opacity": 10,
|
||||
"roughness": 2,
|
||||
"seed": Any<Number>,
|
||||
"strokeColor": "red",
|
||||
"strokeSharpness": "round",
|
||||
"strokeStyle": "dashed",
|
||||
"strokeWidth": 2,
|
||||
"type": "ellipse",
|
||||
"version": 1,
|
||||
"versionNonce": 0,
|
||||
"width": 100,
|
||||
"x": 10,
|
||||
"y": 20,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`restoreElements should restore correctly with rectangle, ellipse and diamond elements 3`] = `
|
||||
Object {
|
||||
"angle": 0,
|
||||
"backgroundColor": "blue",
|
||||
"boundElementIds": Array [],
|
||||
"fillStyle": "cross-hatch",
|
||||
"groupIds": Array [
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
],
|
||||
"height": 200,
|
||||
"id": "3",
|
||||
"isDeleted": false,
|
||||
"opacity": 10,
|
||||
"roughness": 2,
|
||||
"seed": Any<Number>,
|
||||
"strokeColor": "red",
|
||||
"strokeSharpness": "round",
|
||||
"strokeStyle": "dashed",
|
||||
"strokeWidth": 2,
|
||||
"type": "diamond",
|
||||
"version": 1,
|
||||
"versionNonce": 0,
|
||||
"width": 100,
|
||||
"x": 10,
|
||||
"y": 20,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`restoreElements should restore freedraw element correctly 1`] = `
|
||||
Object {
|
||||
"angle": 0,
|
||||
"backgroundColor": "transparent",
|
||||
"boundElementIds": Array [],
|
||||
"fillStyle": "hachure",
|
||||
"groupIds": Array [],
|
||||
"height": 0,
|
||||
"id": "id-freedraw01",
|
||||
"isDeleted": false,
|
||||
"lastCommittedPoint": null,
|
||||
"opacity": 100,
|
||||
"points": Array [],
|
||||
"pressures": Array [],
|
||||
"roughness": 1,
|
||||
"seed": Any<Number>,
|
||||
"simulatePressure": true,
|
||||
"strokeColor": "#000000",
|
||||
"strokeSharpness": "sharp",
|
||||
"strokeStyle": "solid",
|
||||
"strokeWidth": 1,
|
||||
"type": "freedraw",
|
||||
"version": 1,
|
||||
"versionNonce": 0,
|
||||
"width": 0,
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`restoreElements should restore line and draw elements correctly 1`] = `
|
||||
Object {
|
||||
"angle": 0,
|
||||
"backgroundColor": "transparent",
|
||||
"boundElementIds": Array [],
|
||||
"endArrowhead": null,
|
||||
"endBinding": null,
|
||||
"fillStyle": "hachure",
|
||||
"groupIds": Array [],
|
||||
"height": 0,
|
||||
"id": "id-line01",
|
||||
"isDeleted": false,
|
||||
"lastCommittedPoint": null,
|
||||
"opacity": 100,
|
||||
"points": Array [
|
||||
Array [
|
||||
0,
|
||||
0,
|
||||
],
|
||||
Array [
|
||||
0,
|
||||
0,
|
||||
],
|
||||
],
|
||||
"roughness": 1,
|
||||
"seed": Any<Number>,
|
||||
"startArrowhead": null,
|
||||
"startBinding": null,
|
||||
"strokeColor": "#000000",
|
||||
"strokeSharpness": "sharp",
|
||||
"strokeStyle": "solid",
|
||||
"strokeWidth": 1,
|
||||
"type": "line",
|
||||
"version": 1,
|
||||
"versionNonce": 0,
|
||||
"width": 0,
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`restoreElements should restore line and draw elements correctly 2`] = `
|
||||
Object {
|
||||
"angle": 0,
|
||||
"backgroundColor": "transparent",
|
||||
"boundElementIds": Array [],
|
||||
"endArrowhead": null,
|
||||
"endBinding": null,
|
||||
"fillStyle": "hachure",
|
||||
"groupIds": Array [],
|
||||
"height": 0,
|
||||
"id": "id-draw01",
|
||||
"isDeleted": false,
|
||||
"lastCommittedPoint": null,
|
||||
"opacity": 100,
|
||||
"points": Array [
|
||||
Array [
|
||||
0,
|
||||
0,
|
||||
],
|
||||
Array [
|
||||
0,
|
||||
0,
|
||||
],
|
||||
],
|
||||
"roughness": 1,
|
||||
"seed": Any<Number>,
|
||||
"startArrowhead": null,
|
||||
"startBinding": null,
|
||||
"strokeColor": "#000000",
|
||||
"strokeSharpness": "sharp",
|
||||
"strokeStyle": "solid",
|
||||
"strokeWidth": 1,
|
||||
"type": "line",
|
||||
"version": 1,
|
||||
"versionNonce": 0,
|
||||
"width": 0,
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`restoreElements should restore text element correctly passing value for each attribute 1`] = `
|
||||
Object {
|
||||
"angle": 0,
|
||||
"backgroundColor": "transparent",
|
||||
"baseline": 0,
|
||||
"boundElementIds": Array [],
|
||||
"fillStyle": "hachure",
|
||||
"fontFamily": 1,
|
||||
"fontSize": 14,
|
||||
"groupIds": Array [],
|
||||
"height": 0,
|
||||
"id": "id-text01",
|
||||
"isDeleted": false,
|
||||
"opacity": 100,
|
||||
"roughness": 1,
|
||||
"seed": Any<Number>,
|
||||
"strokeColor": "#000000",
|
||||
"strokeSharpness": "sharp",
|
||||
"strokeStyle": "solid",
|
||||
"strokeWidth": 1,
|
||||
"text": "text",
|
||||
"textAlign": "center",
|
||||
"type": "text",
|
||||
"version": 1,
|
||||
"versionNonce": 0,
|
||||
"verticalAlign": "middle",
|
||||
"width": 0,
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`restoreElements should restore text element correctly with unknown font family, null text and undefined alignment 1`] = `
|
||||
Object {
|
||||
"angle": 0,
|
||||
"backgroundColor": "transparent",
|
||||
"baseline": 0,
|
||||
"boundElementIds": Array [],
|
||||
"fillStyle": "hachure",
|
||||
"fontFamily": 1,
|
||||
"fontSize": 10,
|
||||
"groupIds": Array [],
|
||||
"height": 0,
|
||||
"id": "id-text01",
|
||||
"isDeleted": false,
|
||||
"opacity": 100,
|
||||
"roughness": 1,
|
||||
"seed": Any<Number>,
|
||||
"strokeColor": "#000000",
|
||||
"strokeSharpness": "sharp",
|
||||
"strokeStyle": "solid",
|
||||
"strokeWidth": 1,
|
||||
"text": "",
|
||||
"textAlign": "left",
|
||||
"type": "text",
|
||||
"version": 1,
|
||||
"versionNonce": 0,
|
||||
"verticalAlign": "top",
|
||||
"width": 0,
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
}
|
||||
`;
|
Reference in New Issue
Block a user