From 19f21b44f7f98041aa2806c1e2d4f47561038344 Mon Sep 17 00:00:00 2001 From: Malavika Koppula Date: Thu, 3 Aug 2023 14:54:30 -0400 Subject: [PATCH 01/10] Added textfile block --- blocks/textfile-block/CHANGELOG.md | 4 ++++ .../textfile-block/features/textfile/text.js | 19 +++++++++++++++++++ .../features/textfile/text.test.js | 17 +++++++++++++++++ blocks/textfile-block/jest.config.js | 5 +++++ 4 files changed, 45 insertions(+) create mode 100644 blocks/textfile-block/CHANGELOG.md create mode 100644 blocks/textfile-block/features/textfile/text.js create mode 100644 blocks/textfile-block/features/textfile/text.test.js create mode 100644 blocks/textfile-block/jest.config.js diff --git a/blocks/textfile-block/CHANGELOG.md b/blocks/textfile-block/CHANGELOG.md new file mode 100644 index 00000000..e9fb6ecf --- /dev/null +++ b/blocks/textfile-block/CHANGELOG.md @@ -0,0 +1,4 @@ +# Change Log + +All notable changes to this project will be documented in this file. +See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. \ No newline at end of file diff --git a/blocks/textfile-block/features/textfile/text.js b/blocks/textfile-block/features/textfile/text.js new file mode 100644 index 00000000..f396b734 --- /dev/null +++ b/blocks/textfile-block/features/textfile/text.js @@ -0,0 +1,19 @@ +import PropTypes from 'fusion:prop-types' +import Consumer from 'fusion:consumer' + +export function Textfile({ customFields }){ + const { Text = "" } = customFields || {}; + return Text; +}; + +Textfile.label = "Text File – Arc Block"; + +Textfile.icon = "notes-paper-text"; + +Textfile.propTypes = { + customFields: PropTypes.shape({ + // eslint-disable-next-line react/no-typos + Text: PropTypes.richtext, + }), +} +export default Consumer(Textfile) diff --git a/blocks/textfile-block/features/textfile/text.test.js b/blocks/textfile-block/features/textfile/text.test.js new file mode 100644 index 00000000..f67390e6 --- /dev/null +++ b/blocks/textfile-block/features/textfile/text.test.js @@ -0,0 +1,17 @@ +import TextFile from "./text"; + +const simple = "User-agent: *\nAllow: /\n\nSitemap: http://www.example.com/sitemap.xml"; + +it('should render the simple text', () => { + const textFile = TextFile({ + customFields: { + Text: simple + }, + }) + expect(textFile).toMatchSnapshot() +}) + +it('should not render anything when no data is given', () => { + const textFile = TextFile({}) + expect(textFile).toMatchSnapshot() +}) diff --git a/blocks/textfile-block/jest.config.js b/blocks/textfile-block/jest.config.js new file mode 100644 index 00000000..063a34cb --- /dev/null +++ b/blocks/textfile-block/jest.config.js @@ -0,0 +1,5 @@ +const base = require("../../jest/jest.config.base"); + +module.exports = { + ...base, +}; From ca9ee7dc729556e570ffef9867862715705141af Mon Sep 17 00:00:00 2001 From: malavikakoppula <83021791+malavikakoppula@users.noreply.github.com> Date: Mon, 7 Aug 2023 12:41:46 -0400 Subject: [PATCH 02/10] Create soft-jeans-listen.md --- .changeset/soft-jeans-listen.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/soft-jeans-listen.md diff --git a/.changeset/soft-jeans-listen.md b/.changeset/soft-jeans-listen.md new file mode 100644 index 00000000..3032e324 --- /dev/null +++ b/.changeset/soft-jeans-listen.md @@ -0,0 +1,5 @@ +--- + +--- + +Added textfile block From d30281f309fac2953a65f541d6fac87a85cc577e Mon Sep 17 00:00:00 2001 From: Malavika Koppula Date: Mon, 7 Aug 2023 12:47:36 -0400 Subject: [PATCH 03/10] Added package to textfile-block --- blocks/textfile-block/package.json | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 blocks/textfile-block/package.json diff --git a/blocks/textfile-block/package.json b/blocks/textfile-block/package.json new file mode 100644 index 00000000..e1e0c0c4 --- /dev/null +++ b/blocks/textfile-block/package.json @@ -0,0 +1,27 @@ +{ + "name": "@wpmedia/textfile-block", + "version": "0.0.1", + "description": "Fusion News Theme text file block", + "license": "CC-BY-NC-ND-4.0", + "main": "index.js", + "files": [ + "features" + ], + "publishConfig": { + "registry": "https://npm.pkg.github.com/", + "access": "public" + }, + "repository": { + "type": "git", + "url": "ssh://git@github.com/WPMedia/feed-components.git", + "directory": "blocks/textfile-block" + }, + "scripts": { + "test": "echo \"Error: run tests from root\" && exit 1", + "lint": "eslint --ext js --ext jsx features" + }, + "devDependencies": { + "prop-types": "^15.7.2" + }, + "gitHead": "83fb8d6685958d85ddbfcfbf01d9a5c864cd6c95" +} From 67d8c3cf7de550443bd505097b09ae6513c8a813 Mon Sep 17 00:00:00 2001 From: Malavika Koppula Date: Mon, 7 Aug 2023 12:50:04 -0400 Subject: [PATCH 04/10] added package-lock --- blocks/textfile-block/package-lock.json | 46 +++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 blocks/textfile-block/package-lock.json diff --git a/blocks/textfile-block/package-lock.json b/blocks/textfile-block/package-lock.json new file mode 100644 index 00000000..852102e9 --- /dev/null +++ b/blocks/textfile-block/package-lock.json @@ -0,0 +1,46 @@ +{ + "name": "@wpmedia/textfile-block", + "version": "0.0.1", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dev": true, + "requires": { + "js-tokens": "^3.0.0 || ^4.0.0" + } + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "dev": true + }, + "prop-types": { + "version": "15.8.1", + "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", + "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", + "dev": true, + "requires": { + "loose-envify": "^1.4.0", + "object-assign": "^4.1.1", + "react-is": "^16.13.1" + } + }, + "react-is": { + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", + "dev": true + } + } +} From 8afbaf40a307aae41539525a3cb8df33ed8b9458 Mon Sep 17 00:00:00 2001 From: blakeganderson <85515364+blakeganderson@users.noreply.github.com> Date: Mon, 14 Aug 2023 13:38:11 -0400 Subject: [PATCH 05/10] Added text-output-block --- blocks/text-output-block/CHANGELOG.md | 4 +++ blocks/text-output-block/README.md | 3 +++ blocks/text-output-block/index.js | 1 + blocks/text-output-block/jest.config.js | 5 ++++ .../text-output-block/output-types/.npmignore | 1 + blocks/text-output-block/output-types/text.js | 18 +++++++++++++ .../output-types/text.test.jsx | 24 +++++++++++++++++ blocks/text-output-block/package-lock.json | 5 ++++ blocks/text-output-block/package.json | 27 +++++++++++++++++++ 9 files changed, 88 insertions(+) create mode 100644 blocks/text-output-block/CHANGELOG.md create mode 100644 blocks/text-output-block/README.md create mode 100644 blocks/text-output-block/index.js create mode 100644 blocks/text-output-block/jest.config.js create mode 100644 blocks/text-output-block/output-types/.npmignore create mode 100644 blocks/text-output-block/output-types/text.js create mode 100644 blocks/text-output-block/output-types/text.test.jsx create mode 100644 blocks/text-output-block/package-lock.json create mode 100644 blocks/text-output-block/package.json diff --git a/blocks/text-output-block/CHANGELOG.md b/blocks/text-output-block/CHANGELOG.md new file mode 100644 index 00000000..e4d87c4d --- /dev/null +++ b/blocks/text-output-block/CHANGELOG.md @@ -0,0 +1,4 @@ +# Change Log + +All notable changes to this project will be documented in this file. +See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. diff --git a/blocks/text-output-block/README.md b/blocks/text-output-block/README.md new file mode 100644 index 00000000..17d8c029 --- /dev/null +++ b/blocks/text-output-block/README.md @@ -0,0 +1,3 @@ +# Text Output Type + +Used to generate text output diff --git a/blocks/text-output-block/index.js b/blocks/text-output-block/index.js new file mode 100644 index 00000000..f053ebf7 --- /dev/null +++ b/blocks/text-output-block/index.js @@ -0,0 +1 @@ +module.exports = {}; diff --git a/blocks/text-output-block/jest.config.js b/blocks/text-output-block/jest.config.js new file mode 100644 index 00000000..063a34cb --- /dev/null +++ b/blocks/text-output-block/jest.config.js @@ -0,0 +1,5 @@ +const base = require("../../jest/jest.config.base"); + +module.exports = { + ...base, +}; diff --git a/blocks/text-output-block/output-types/.npmignore b/blocks/text-output-block/output-types/.npmignore new file mode 100644 index 00000000..0b1107c2 --- /dev/null +++ b/blocks/text-output-block/output-types/.npmignore @@ -0,0 +1 @@ +*.test.jsx \ No newline at end of file diff --git a/blocks/text-output-block/output-types/text.js b/blocks/text-output-block/output-types/text.js new file mode 100644 index 00000000..9a19dd1d --- /dev/null +++ b/blocks/text-output-block/output-types/text.js @@ -0,0 +1,18 @@ +import PropTypes from 'prop-types' + +const TextOutputType = ({ children }) => { + const generateText = (child) => { + if (Array.isArray(child)) return child.map(generateText).join('\n') + return child + } + return generateText(children) +} + +TextOutputType.contentType = 'text/plain' +TextOutputType.fallback = false + +TextOutputType.propTypes = { + children: PropTypes.node, +} + +export default TextOutputType diff --git a/blocks/text-output-block/output-types/text.test.jsx b/blocks/text-output-block/output-types/text.test.jsx new file mode 100644 index 00000000..d14283df --- /dev/null +++ b/blocks/text-output-block/output-types/text.test.jsx @@ -0,0 +1,24 @@ +/** + * this is for mocking node env + * will not have window attribute, testing ssr + * https://jestjs.io/docs/en/configuration.html#testenvironment-string + * @jest-environment node + */ +import React from "react"; +import { shallow } from "enzyme"; +import TextOutputType from "./text"; + +describe("the text output type", () => { + it("should render", () => { + const wrapper = shallow(); + expect(wrapper).toBeDefined(); + }); + + describe("renders a page", () => { + const wrapper = shallow(hello world); + + it("should render the childs plain", () => { + expect(wrapper.text()).toEqual("hello world"); + }); + }); +}); diff --git a/blocks/text-output-block/package-lock.json b/blocks/text-output-block/package-lock.json new file mode 100644 index 00000000..c651a8d2 --- /dev/null +++ b/blocks/text-output-block/package-lock.json @@ -0,0 +1,5 @@ +{ + "name": "@wpmedia/text-output-block", + "version": "5.14.1", + "lockfileVersion": 1 +} diff --git a/blocks/text-output-block/package.json b/blocks/text-output-block/package.json new file mode 100644 index 00000000..fea1bbc5 --- /dev/null +++ b/blocks/text-output-block/package.json @@ -0,0 +1,27 @@ +{ + "name": "@wpmedia/text-output-block", + "version": "0.0.1", + "description": "Fusion News Theme text output block", + "main": "index.js", + "files": [ + "output-types" + ], + "license": "CC-BY-NC-ND-4.0", + "repository": { + "type": "git", + "url": "ssh://git@github.com/WPMedia/feed-components.git", + "directory": "blocks/text-output-block" + }, + "publishConfig": { + "registry": "https://npm.pkg.github.com/", + "access": "public" + }, + "scripts": { + "test": "echo \"Error: run tests from root\" && exit 1", + "lint": "eslint --ext js --ext jsx features" + }, + "devDependencies": { + "prop-types": "^15.7.2" + }, + "gitHead": "83fb8d6685958d85ddbfcfbf01d9a5c864cd6c95" +} From 89db185482f8239e3f68c79984bb59e8b4986f75 Mon Sep 17 00:00:00 2001 From: blakeganderson <85515364+blakeganderson@users.noreply.github.com> Date: Mon, 14 Aug 2023 16:33:01 -0400 Subject: [PATCH 06/10] removed textfile block --- blocks/textfile-block/CHANGELOG.md | 4 -- .../textfile-block/features/textfile/text.js | 19 -------- .../features/textfile/text.test.js | 17 ------- blocks/textfile-block/jest.config.js | 5 -- blocks/textfile-block/package-lock.json | 46 ------------------- blocks/textfile-block/package.json | 27 ----------- 6 files changed, 118 deletions(-) delete mode 100644 blocks/textfile-block/CHANGELOG.md delete mode 100644 blocks/textfile-block/features/textfile/text.js delete mode 100644 blocks/textfile-block/features/textfile/text.test.js delete mode 100644 blocks/textfile-block/jest.config.js delete mode 100644 blocks/textfile-block/package-lock.json delete mode 100644 blocks/textfile-block/package.json diff --git a/blocks/textfile-block/CHANGELOG.md b/blocks/textfile-block/CHANGELOG.md deleted file mode 100644 index e9fb6ecf..00000000 --- a/blocks/textfile-block/CHANGELOG.md +++ /dev/null @@ -1,4 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. \ No newline at end of file diff --git a/blocks/textfile-block/features/textfile/text.js b/blocks/textfile-block/features/textfile/text.js deleted file mode 100644 index f396b734..00000000 --- a/blocks/textfile-block/features/textfile/text.js +++ /dev/null @@ -1,19 +0,0 @@ -import PropTypes from 'fusion:prop-types' -import Consumer from 'fusion:consumer' - -export function Textfile({ customFields }){ - const { Text = "" } = customFields || {}; - return Text; -}; - -Textfile.label = "Text File – Arc Block"; - -Textfile.icon = "notes-paper-text"; - -Textfile.propTypes = { - customFields: PropTypes.shape({ - // eslint-disable-next-line react/no-typos - Text: PropTypes.richtext, - }), -} -export default Consumer(Textfile) diff --git a/blocks/textfile-block/features/textfile/text.test.js b/blocks/textfile-block/features/textfile/text.test.js deleted file mode 100644 index f67390e6..00000000 --- a/blocks/textfile-block/features/textfile/text.test.js +++ /dev/null @@ -1,17 +0,0 @@ -import TextFile from "./text"; - -const simple = "User-agent: *\nAllow: /\n\nSitemap: http://www.example.com/sitemap.xml"; - -it('should render the simple text', () => { - const textFile = TextFile({ - customFields: { - Text: simple - }, - }) - expect(textFile).toMatchSnapshot() -}) - -it('should not render anything when no data is given', () => { - const textFile = TextFile({}) - expect(textFile).toMatchSnapshot() -}) diff --git a/blocks/textfile-block/jest.config.js b/blocks/textfile-block/jest.config.js deleted file mode 100644 index 063a34cb..00000000 --- a/blocks/textfile-block/jest.config.js +++ /dev/null @@ -1,5 +0,0 @@ -const base = require("../../jest/jest.config.base"); - -module.exports = { - ...base, -}; diff --git a/blocks/textfile-block/package-lock.json b/blocks/textfile-block/package-lock.json deleted file mode 100644 index 852102e9..00000000 --- a/blocks/textfile-block/package-lock.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "name": "@wpmedia/textfile-block", - "version": "0.0.1", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "js-tokens": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "dev": true - }, - "loose-envify": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", - "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", - "dev": true, - "requires": { - "js-tokens": "^3.0.0 || ^4.0.0" - } - }, - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", - "dev": true - }, - "prop-types": { - "version": "15.8.1", - "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", - "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", - "dev": true, - "requires": { - "loose-envify": "^1.4.0", - "object-assign": "^4.1.1", - "react-is": "^16.13.1" - } - }, - "react-is": { - "version": "16.13.1", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", - "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", - "dev": true - } - } -} diff --git a/blocks/textfile-block/package.json b/blocks/textfile-block/package.json deleted file mode 100644 index e1e0c0c4..00000000 --- a/blocks/textfile-block/package.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "@wpmedia/textfile-block", - "version": "0.0.1", - "description": "Fusion News Theme text file block", - "license": "CC-BY-NC-ND-4.0", - "main": "index.js", - "files": [ - "features" - ], - "publishConfig": { - "registry": "https://npm.pkg.github.com/", - "access": "public" - }, - "repository": { - "type": "git", - "url": "ssh://git@github.com/WPMedia/feed-components.git", - "directory": "blocks/textfile-block" - }, - "scripts": { - "test": "echo \"Error: run tests from root\" && exit 1", - "lint": "eslint --ext js --ext jsx features" - }, - "devDependencies": { - "prop-types": "^15.7.2" - }, - "gitHead": "83fb8d6685958d85ddbfcfbf01d9a5c864cd6c95" -} From 2805c3bb1b66f09b6e95349281d565fa8d0e5705 Mon Sep 17 00:00:00 2001 From: blakeganderson <85515364+blakeganderson@users.noreply.github.com> Date: Mon, 14 Aug 2023 16:39:51 -0400 Subject: [PATCH 07/10] removed changeset from THEMES-927 --- .changeset/soft-jeans-listen.md | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .changeset/soft-jeans-listen.md diff --git a/.changeset/soft-jeans-listen.md b/.changeset/soft-jeans-listen.md deleted file mode 100644 index 3032e324..00000000 --- a/.changeset/soft-jeans-listen.md +++ /dev/null @@ -1,5 +0,0 @@ ---- - ---- - -Added textfile block From f1b5ff34e5e468f928b4d73d7359c313d39f4ec5 Mon Sep 17 00:00:00 2001 From: blakeganderson <85515364+blakeganderson@users.noreply.github.com> Date: Mon, 14 Aug 2023 16:47:26 -0400 Subject: [PATCH 08/10] Create fluffy-elephants-care.md --- .changeset/fluffy-elephants-care.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fluffy-elephants-care.md diff --git a/.changeset/fluffy-elephants-care.md b/.changeset/fluffy-elephants-care.md new file mode 100644 index 00000000..a710b33d --- /dev/null +++ b/.changeset/fluffy-elephants-care.md @@ -0,0 +1,5 @@ +--- +"@wpmedia/text-output-block": patch +--- + +Added text output block From 8039f3ff2b50d5ca659f6894e70f0deee1ad4b34 Mon Sep 17 00:00:00 2001 From: Malavika Koppula Date: Wed, 13 Sep 2023 13:08:00 -0400 Subject: [PATCH 09/10] Fixed tests and output-block --- .eslintrc.js | 7 +-- .../package-lock.json | 2 +- .../__snapshots__/text.test.jsx.snap | 3 ++ blocks/text-output-block/output-types/text.js | 17 +++---- .../output-types/text.test.jsx | 26 +++++------ blocks/text-output-block/package-lock.json | 45 ++++++++++++++++++- 6 files changed, 71 insertions(+), 29 deletions(-) create mode 100644 blocks/text-output-block/output-types/__snapshots__/text.test.jsx.snap diff --git a/.eslintrc.js b/.eslintrc.js index 1bdb6ffe..11dda2b4 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -12,9 +12,10 @@ module.exports = { overrides: [ { files: ['*.test.js', '__mocks__/**'], - env: { - jest: true, - }, + }, ], + env: { + jest: true, + }, } diff --git a/blocks/sitemap-section-feature-block/package-lock.json b/blocks/sitemap-section-feature-block/package-lock.json index 9aa01151..bb3e8927 100644 --- a/blocks/sitemap-section-feature-block/package-lock.json +++ b/blocks/sitemap-section-feature-block/package-lock.json @@ -1,6 +1,6 @@ { "name": "@wpmedia/sitemap-section-feature-block", - "version": "1.14.0", + "version": "1.14.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/blocks/text-output-block/output-types/__snapshots__/text.test.jsx.snap b/blocks/text-output-block/output-types/__snapshots__/text.test.jsx.snap new file mode 100644 index 00000000..cfa21682 --- /dev/null +++ b/blocks/text-output-block/output-types/__snapshots__/text.test.jsx.snap @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should match the snapshot 1`] = `"hello world"`; diff --git a/blocks/text-output-block/output-types/text.js b/blocks/text-output-block/output-types/text.js index 9a19dd1d..024ea053 100644 --- a/blocks/text-output-block/output-types/text.js +++ b/blocks/text-output-block/output-types/text.js @@ -1,18 +1,19 @@ import PropTypes from 'prop-types' +import Consumer from 'fusion:consumer' -const TextOutputType = ({ children }) => { - const generateText = (child) => { +export function TextOutputType(children){ + const generateText = (child) => { if (Array.isArray(child)) return child.map(generateText).join('\n') return child } return generateText(children) -} +}; + +TextOutputType.contentType = "text/plain"; -TextOutputType.contentType = 'text/plain' -TextOutputType.fallback = false +TextOutputType.fallback = false; TextOutputType.propTypes = { - children: PropTypes.node, + children: PropTypes.node, } - -export default TextOutputType +export default Consumer(TextOutputType) diff --git a/blocks/text-output-block/output-types/text.test.jsx b/blocks/text-output-block/output-types/text.test.jsx index d14283df..0624cb2c 100644 --- a/blocks/text-output-block/output-types/text.test.jsx +++ b/blocks/text-output-block/output-types/text.test.jsx @@ -4,21 +4,17 @@ * https://jestjs.io/docs/en/configuration.html#testenvironment-string * @jest-environment node */ -import React from "react"; -import { shallow } from "enzyme"; -import TextOutputType from "./text"; +// eslint-disable-next-line no-unused-vars +import Consumer from 'fusion:consumer' +import {TextOutputType} from "./text"; -describe("the text output type", () => { - it("should render", () => { - const wrapper = shallow(); - expect(wrapper).toBeDefined(); - }); +it('should match the snapshot', () => { + const videoSitemap = TextOutputType("hello world") + expect(videoSitemap).toMatchSnapshot() + }) - describe("renders a page", () => { - const wrapper = shallow(hello world); - - it("should render the childs plain", () => { - expect(wrapper.text()).toEqual("hello world"); - }); - }); +it("should render array of children as plain text", () => { + const videoSitemap = TextOutputType(["hello world", "print output"]) + expect(videoSitemap).toEqual("hello world\nprint output"); }); + diff --git a/blocks/text-output-block/package-lock.json b/blocks/text-output-block/package-lock.json index c651a8d2..e6cff754 100644 --- a/blocks/text-output-block/package-lock.json +++ b/blocks/text-output-block/package-lock.json @@ -1,5 +1,46 @@ { "name": "@wpmedia/text-output-block", - "version": "5.14.1", - "lockfileVersion": 1 + "version": "0.0.1", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dev": true, + "requires": { + "js-tokens": "^3.0.0 || ^4.0.0" + } + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "dev": true + }, + "prop-types": { + "version": "15.8.1", + "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", + "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", + "dev": true, + "requires": { + "loose-envify": "^1.4.0", + "object-assign": "^4.1.1", + "react-is": "^16.13.1" + } + }, + "react-is": { + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", + "dev": true + } + } } From eb27f54e7678040ec81acdb4308002c9c719b2b0 Mon Sep 17 00:00:00 2001 From: Malavika Koppula Date: Thu, 21 Sep 2023 08:42:33 -0400 Subject: [PATCH 10/10] Added EOL --- blocks/text-output-block/output-types/.npmignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blocks/text-output-block/output-types/.npmignore b/blocks/text-output-block/output-types/.npmignore index 0b1107c2..204437f3 100644 --- a/blocks/text-output-block/output-types/.npmignore +++ b/blocks/text-output-block/output-types/.npmignore @@ -1 +1 @@ -*.test.jsx \ No newline at end of file +*.test.jsx