-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #654 from WPMedia/THEMES-926
Themes 926
- Loading branch information
Showing
13 changed files
with
139 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@wpmedia/text-output-block": patch | ||
--- | ||
|
||
Added text output block |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Text Output Type | ||
|
||
Used to generate text output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const base = require("../../jest/jest.config.base"); | ||
|
||
module.exports = { | ||
...base, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.test.jsx |
3 changes: 3 additions & 0 deletions
3
blocks/text-output-block/output-types/__snapshots__/text.test.jsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`should match the snapshot 1`] = `"hello world"`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import PropTypes from 'prop-types' | ||
import Consumer from 'fusion:consumer' | ||
|
||
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.fallback = false; | ||
|
||
TextOutputType.propTypes = { | ||
children: PropTypes.node, | ||
} | ||
export default Consumer(TextOutputType) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* 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 | ||
*/ | ||
// eslint-disable-next-line no-unused-vars | ||
import Consumer from 'fusion:consumer' | ||
import {TextOutputType} from "./text"; | ||
|
||
it('should match the snapshot', () => { | ||
const videoSitemap = TextOutputType("hello world") | ||
expect(videoSitemap).toMatchSnapshot() | ||
}) | ||
|
||
it("should render array of children as plain text", () => { | ||
const videoSitemap = TextOutputType(["hello world", "print output"]) | ||
expect(videoSitemap).toEqual("hello world\nprint output"); | ||
}); | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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://[email protected]/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" | ||
} |