From cb36566db661f7010a80bf86fd705f0a1eb817dd Mon Sep 17 00:00:00 2001 From: Stefanos Anagnostou Date: Mon, 16 Dec 2024 13:14:49 +0200 Subject: [PATCH] chore(clerk-js): Add snapshot test for `PublicUserData` (#4782) --- .changeset/stale-cougars-roll.md | 2 ++ .../resources/__tests__/PublicUserData.test.ts | 18 ++++++++++++++++++ .../__snapshots__/PublicUserData.test.ts.snap | 3 +++ 3 files changed, 23 insertions(+) create mode 100644 .changeset/stale-cougars-roll.md create mode 100644 packages/clerk-js/src/core/resources/__tests__/PublicUserData.test.ts create mode 100644 packages/clerk-js/src/core/resources/__tests__/__snapshots__/PublicUserData.test.ts.snap diff --git a/.changeset/stale-cougars-roll.md b/.changeset/stale-cougars-roll.md new file mode 100644 index 0000000000..a845151cc8 --- /dev/null +++ b/.changeset/stale-cougars-roll.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/packages/clerk-js/src/core/resources/__tests__/PublicUserData.test.ts b/packages/clerk-js/src/core/resources/__tests__/PublicUserData.test.ts new file mode 100644 index 0000000000..cf5f4473fd --- /dev/null +++ b/packages/clerk-js/src/core/resources/__tests__/PublicUserData.test.ts @@ -0,0 +1,18 @@ +import { PublicUserData } from '../PublicUserData'; + +describe('PublicUserData', () => { + it('JSON.stringify returns the same object structure', () => { + const pud = new PublicUserData({ + object: 'public_user_data', + id: '123', + first_name: 'John', + last_name: 'Doe', + image_url: 'https://example.com/image.jpg', + has_image: true, + identifier: 'john-doe', + user_id: '123', + }); + + expect(JSON.stringify(pud)).toMatchSnapshot(); + }); +}); diff --git a/packages/clerk-js/src/core/resources/__tests__/__snapshots__/PublicUserData.test.ts.snap b/packages/clerk-js/src/core/resources/__tests__/__snapshots__/PublicUserData.test.ts.snap new file mode 100644 index 0000000000..01673ae963 --- /dev/null +++ b/packages/clerk-js/src/core/resources/__tests__/__snapshots__/PublicUserData.test.ts.snap @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`PublicUserData JSON.stringify returns the same object structure 1`] = `"{"firstName":"John","lastName":"Doe","imageUrl":"https://example.com/image.jpg","hasImage":true,"identifier":"john-doe","userId":"123"}"`;