From 8aed24312fd27c9f03f8a501d02a6674c3771765 Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Thu, 3 Aug 2023 12:14:21 +0530 Subject: [PATCH] fix snaps --- src/data/__snapshots__/transform.test.ts.snap | 413 +++++++++++++----- src/data/transform.test.ts | 42 +- 2 files changed, 336 insertions(+), 119 deletions(-) diff --git a/src/data/__snapshots__/transform.test.ts.snap b/src/data/__snapshots__/transform.test.ts.snap index 9b048f4fb4..76866448f2 100644 --- a/src/data/__snapshots__/transform.test.ts.snap +++ b/src/data/__snapshots__/transform.test.ts.snap @@ -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, + "isDeleted": false, + "link": null, + "locked": false, + "opacity": 100, + "roughness": 1, + "roundness": null, + "seed": Any, + "strokeColor": "#1e1e1e", + "strokeStyle": "solid", + "strokeWidth": 1, + "type": "rectangle", + "updated": 1, + "version": 1, + "versionNonce": Any, + "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, + "isDeleted": false, + "link": null, + "locked": false, + "opacity": 100, + "roughness": 1, + "roundness": null, + "seed": Any, + "strokeColor": "#1e1e1e", + "strokeStyle": "solid", + "strokeWidth": 1, + "type": "rectangle", + "updated": 1, + "version": 1, + "versionNonce": Any, + "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, + "isDeleted": false, + "link": null, + "locked": false, + "opacity": 100, + "roughness": 1, + "roundness": null, + "seed": Any, + "strokeColor": "#1e1e1e", + "strokeStyle": "solid", + "strokeWidth": 1, + "type": "rectangle", + "updated": 1, + "version": 1, + "versionNonce": Any, + "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, + "isDeleted": false, + "link": null, + "locked": false, + "opacity": 100, + "roughness": 1, + "roundness": null, + "seed": Any, + "strokeColor": "#1e1e1e", + "strokeStyle": "solid", + "strokeWidth": 1, + "type": "ellipse", + "updated": 1, + "version": 1, + "versionNonce": Any, + "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, + "isDeleted": false, + "link": null, + "locked": false, + "opacity": 100, + "roughness": 1, + "roundness": null, + "seed": Any, + "strokeColor": "#1e1e1e", + "strokeStyle": "solid", + "strokeWidth": 1, + "type": "diamond", + "updated": 1, + "version": 1, + "versionNonce": Any, + "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, + "isDeleted": false, + "link": null, + "locked": false, + "opacity": 100, + "roughness": 1, + "roundness": null, + "seed": Any, + "strokeColor": "#1e1e1e", + "strokeStyle": "solid", + "strokeWidth": 2, + "type": "rectangle", + "updated": 1, + "version": 1, + "versionNonce": Any, + "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, + "isDeleted": false, + "link": null, + "locked": false, + "opacity": 100, + "roughness": 1, + "roundness": null, + "seed": Any, + "strokeColor": "#1e1e1e", + "strokeStyle": "dotted", + "strokeWidth": 2, + "type": "ellipse", + "updated": 1, + "version": 1, + "versionNonce": Any, + "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, + "isDeleted": false, + "link": null, + "locked": false, + "opacity": 100, + "roughness": 1, + "roundness": null, + "seed": Any, + "strokeColor": "#1971c2", + "strokeStyle": "dashed", + "strokeWidth": 2, + "type": "diamond", + "updated": 1, + "version": 1, + "versionNonce": Any, + "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, + "isDeleted": false, + "lineHeight": 1.25, + "link": null, + "locked": false, + "opacity": 100, + "originalText": "HELLO WORLD!", + "roughness": 1, + "roundness": null, + "seed": Any, + "strokeColor": "#1e1e1e", + "strokeStyle": "solid", + "strokeWidth": 1, + "text": "HELLO WORLD!", + "textAlign": "left", + "type": "text", + "updated": 1, + "version": 1, + "versionNonce": Any, + "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, + "isDeleted": false, + "lineHeight": 1.25, + "link": null, + "locked": false, + "opacity": 100, + "originalText": "STYLED HELLO WORLD!", + "roughness": 1, + "roundness": null, + "seed": Any, + "strokeColor": "#5f3dc4", + "strokeStyle": "solid", + "strokeWidth": 1, + "text": "STYLED HELLO WORLD!", + "textAlign": "left", + "type": "text", + "updated": 1, + "version": 1, + "versionNonce": Any, + "verticalAlign": "top", + "width": 190, + "x": 100, + "y": 150, +} `; exports[`Test Transform > should transform to labelled arrows when label provided for arrows 1`] = ` diff --git a/src/data/transform.test.ts b/src/data/transform.test.ts index 409e06f96e..63847454ee 100644 --- a/src/data/transform.test.ts +++ b/src/data/transform.test.ts @@ -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), + }); + }); }); });