From bd41697a28450bdba3a084dfc9a87bafadb23ccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcholas=20Oliveira?= Date: Mon, 10 Jun 2024 13:51:33 -0300 Subject: [PATCH] test: add new blocks renderer test --- package.json | 1 + packages/core/package.json | 1 + .../components/__tests__/BlocksRenderer.tsx | 18 ++++++++++++++++++ .../__snapshots__/BlocksRenderer.tsx.snap | 15 +++++++++++++++ .../next-redis-cache-provider/package.json | 3 ++- packages/next/package.json | 1 + turbo.json | 12 ++++++++++++ 7 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 packages/core/src/react/components/__tests__/__snapshots__/BlocksRenderer.tsx.snap diff --git a/package.json b/package.json index 52469dead..21733cdfa 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "build:packages": "turbo run build --filter=./packages/*", "build:wpnextjs": "turbo run build --filter=./projects/wp-nextjs", "test": "turbo run test", + "test:watch": "turbo run test:watch", "lint": "turbo run lint", "wp-env": "npm run wp-env:start -w=wp/headless-wp", "dev": "turbo run dev --parallel --filter=!./projects/wp-multisite-nextjs --filter=!./projects/wp-multisite-i18n-nextjs", diff --git a/packages/core/package.json b/packages/core/package.json index ab8fcc9c4..28024cd55 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -48,6 +48,7 @@ "watch:ts:cjs": "npm run ts:cjs -- --watch", "watch:ts": "npm run ts -- --watch", "test": "jest", + "test:watch": "jest --watch", "lint": "eslint src/" }, "devDependencies": { diff --git a/packages/core/src/react/components/__tests__/BlocksRenderer.tsx b/packages/core/src/react/components/__tests__/BlocksRenderer.tsx index 5a9b7d62f..9bd53c039 100644 --- a/packages/core/src/react/components/__tests__/BlocksRenderer.tsx +++ b/packages/core/src/react/components/__tests__/BlocksRenderer.tsx @@ -203,4 +203,22 @@ describe('BlocksRenderer', () => { `); }); + + it('works correctly with chinese content', () => { + const StrongToDiv = ({ domNode, children }: BlockProps) => { + const className = + domNode instanceof Element ? domNode?.attribs.class || undefined : undefined; + return
{children}
; + }; + + const { container } = render( + 活動期間`} + > + + , + ); + + expect(container).toMatchSnapshot(); + }); }); diff --git a/packages/core/src/react/components/__tests__/__snapshots__/BlocksRenderer.tsx.snap b/packages/core/src/react/components/__tests__/__snapshots__/BlocksRenderer.tsx.snap new file mode 100644 index 000000000..60cb6caa8 --- /dev/null +++ b/packages/core/src/react/components/__tests__/__snapshots__/BlocksRenderer.tsx.snap @@ -0,0 +1,15 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`BlocksRenderer works correctly with chinese content 1`] = ` +
+

+ + 活動期間 + +

+
+`; diff --git a/packages/next-redis-cache-provider/package.json b/packages/next-redis-cache-provider/package.json index cb7f5cb78..868494a5e 100644 --- a/packages/next-redis-cache-provider/package.json +++ b/packages/next-redis-cache-provider/package.json @@ -21,7 +21,8 @@ "dev": "npm run watch:ts", "watch:ts": "npm run ts -- --watch", "lint": "eslint src", - "test": "jest" + "test": "jest", + "test:watch": "jest --watch" }, "dependencies": { "ioredis": "^5.3.1" diff --git a/packages/next/package.json b/packages/next/package.json index f28870f4b..2269f8ee6 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -46,6 +46,7 @@ "watch:ts:cjs": "npm run ts:cjs -- --watch", "watch:ts": "npm run ts -- --watch", "test": "jest", + "test:watch": "jest --watch", "lint": "eslint src" }, "dependencies": { diff --git a/turbo.json b/turbo.json index 268de177c..725121ec3 100644 --- a/turbo.json +++ b/turbo.json @@ -22,6 +22,18 @@ "test/**/*.ts" ] }, + "test:watch": { + "persistent": true, + "dependsOn": ["@headstartwp/core#build", "@headstartwp/next#build"], + "outputs": [ + "" + ], + "inputs": [ + "src/**/*.tsx", + "src/**/*.ts", + "test/**/*.ts" + ] + }, "lint": { "outputs": [ ""