Skip to content

Commit

Permalink
Add a block fixtures framework to allow automated checking of block v…
Browse files Browse the repository at this point in the history
…alidation (#18643)

Co-authored-by: Glen Davies <glen.davies@a8c.com>
  • Loading branch information
glendaviesnz and Glen Davies committed Feb 17, 2021
1 parent 3fa52d0 commit 1ee629e
Show file tree
Hide file tree
Showing 13 changed files with 563 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- wp:jetpack/send-a-message -->
<div class="wp-block-jetpack-send-a-message"><!-- wp:jetpack/whatsapp-button {"countryCode":"61CX","phoneNumber":"267 8888","firstMessage":"My Message"} -->
<div class="wp-block-jetpack-whatsapp-button is-color-dark"><a class="whatsapp-block__button" href="https://api.whatsapp.com/send?phone=612678888&amp;text=My%20Message" style="background-color:#25D366;color:#fff" target="_self" rel="noopener noreferrer">Chat on WhatsApp</a></div>
<!-- /wp:jetpack/whatsapp-button --></div>
<!-- /wp:jetpack/send-a-message -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[
{
"clientId": "_clientId_0",
"name": "jetpack/send-a-message",
"isValid": true,
"attributes": {},
"innerBlocks": [
{
"clientId": "_clientId_0",
"name": "jetpack/whatsapp-button",
"isValid": true,
"attributes": {
"countryCode": "61CX",
"phoneNumber": "267 8888",
"firstMessage": "My Message",
"buttonText": [
"Chat on WhatsApp"
],
"backgroundColor": "#25D366",
"colorClass": "dark",
"openInNewTab": false
},
"innerBlocks": [],
"originalContent": "<div class=\"wp-block-jetpack-whatsapp-button is-color-dark\"><a class=\"whatsapp-block__button\" href=\"https://api.whatsapp.com/send?phone=612678888&amp;text=My%20Message\" style=\"background-color:#25D366;color:#fff\" target=\"_self\" rel=\"noopener noreferrer\">Chat on WhatsApp</a></div>"
}
],
"originalContent": "<div class=\"wp-block-jetpack-send-a-message\"></div>"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[
{
"blockName": "jetpack/send-a-message",
"attrs": {},
"innerBlocks": [
{
"blockName": "jetpack/whatsapp-button",
"attrs": {
"countryCode": "61CX",
"phoneNumber": "267 8888",
"firstMessage": "My Message"
},
"innerBlocks": [],
"innerHTML": "\n\t<div class=\"wp-block-jetpack-whatsapp-button is-color-dark\"><a class=\"whatsapp-block__button\" href=\"https://api.whatsapp.com/send?phone=612678888&amp;text=My%20Message\" style=\"background-color:#25D366;color:#fff\" target=\"_self\" rel=\"noopener noreferrer\">Chat on WhatsApp</a></div>\n\t",
"innerContent": [
"\n\t<div class=\"wp-block-jetpack-whatsapp-button is-color-dark\"><a class=\"whatsapp-block__button\" href=\"https://api.whatsapp.com/send?phone=612678888&amp;text=My%20Message\" style=\"background-color:#25D366;color:#fff\" target=\"_self\" rel=\"noopener noreferrer\">Chat on WhatsApp</a></div>\n\t"
]
}
],
"innerHTML": "\n<div class=\"wp-block-jetpack-send-a-message\"></div>\n\t",
"innerContent": [
"\n<div class=\"wp-block-jetpack-send-a-message\">",
null,
"</div>\n\t"
]
},
{
"blockName": null,
"attrs": {},
"innerBlocks": [],
"innerHTML": "\n",
"innerContent": [
"\n"
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- wp:jetpack/send-a-message -->
<div class="wp-block-jetpack-send-a-message"><!-- wp:jetpack/whatsapp-button {"countryCode":"61CX","phoneNumber":"267 8888","firstMessage":"My Message"} -->
<div class="wp-block-jetpack-whatsapp-button is-color-dark"><a class="whatsapp-block__button" href="https://api.whatsapp.com/send?phone=612678888&amp;text=My%20Message" style="background-color:#25D366;color:#fff" target="_self" rel="noopener noreferrer">Chat on WhatsApp</a></div>
<!-- /wp:jetpack/whatsapp-button --></div>
<!-- /wp:jetpack/send-a-message -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- wp:jetpack/send-a-message -->
<div class="wp-block-jetpack-send-a-message"><!-- wp:jetpack/whatsapp-button {"countryCode":"61CX","phoneNumber":"267 8888","firstMessage":"My Message"} -->
<div class="wp-block-jetpack-whatsapp-button is-color-dark"><a class="whatsapp-block__button" href="https://api.whatsapp.com/send?phone=612678888&amp;text=My%20Message" style="background-color:#25D366;" target="_self" rel="noopener noreferrer">Chat on WhatsApp</a></div>
<!-- /wp:jetpack/whatsapp-button --></div>
<!-- /wp:jetpack/send-a-message -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[
{
"clientId": "_clientId_0",
"name": "jetpack/send-a-message",
"isValid": true,
"attributes": {},
"innerBlocks": [
{
"clientId": "_clientId_0",
"name": "jetpack/whatsapp-button",
"isValid": true,
"attributes": {
"countryCode": "61CX",
"phoneNumber": "267 8888",
"firstMessage": "My Message",
"buttonText": [
"Chat on WhatsApp"
],
"backgroundColor": "#25D366",
"colorClass": "dark",
"openInNewTab": false
},
"innerBlocks": [],
"originalContent": "<div class=\"wp-block-jetpack-whatsapp-button is-color-dark\"><a class=\"whatsapp-block__button\" href=\"https://api.whatsapp.com/send?phone=612678888&amp;text=My%20Message\" style=\"background-color:#25D366;\" target=\"_self\" rel=\"noopener noreferrer\">Chat on WhatsApp</a></div>"
}
],
"originalContent": "<div class=\"wp-block-jetpack-send-a-message\"></div>"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[
{
"blockName": "jetpack/send-a-message",
"attrs": {},
"innerBlocks": [
{
"blockName": "jetpack/whatsapp-button",
"attrs": {
"countryCode": "61CX",
"phoneNumber": "267 8888",
"firstMessage": "My Message"
},
"innerBlocks": [],
"innerHTML": "\n\t<div class=\"wp-block-jetpack-whatsapp-button is-color-dark\"><a class=\"whatsapp-block__button\" href=\"https://api.whatsapp.com/send?phone=612678888&amp;text=My%20Message\" style=\"background-color:#25D366;\" target=\"_self\" rel=\"noopener noreferrer\">Chat on WhatsApp</a></div>\n\t",
"innerContent": [
"\n\t<div class=\"wp-block-jetpack-whatsapp-button is-color-dark\"><a class=\"whatsapp-block__button\" href=\"https://api.whatsapp.com/send?phone=612678888&amp;text=My%20Message\" style=\"background-color:#25D366;\" target=\"_self\" rel=\"noopener noreferrer\">Chat on WhatsApp</a></div>\n\t"
]
}
],
"innerHTML": "\n<div class=\"wp-block-jetpack-send-a-message\"></div>\n\t",
"innerContent": [
"\n<div class=\"wp-block-jetpack-send-a-message\">",
null,
"</div>\n\t"
]
},
{
"blockName": null,
"attrs": {},
"innerBlocks": [],
"innerHTML": "\n",
"innerContent": [
"\n"
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- wp:jetpack/send-a-message -->
<div class="wp-block-jetpack-send-a-message"><!-- wp:jetpack/whatsapp-button {"countryCode":"61CX","phoneNumber":"267 8888","firstMessage":"My Message"} -->
<div class="wp-block-jetpack-whatsapp-button is-color-dark"><a class="whatsapp-block__button" href="https://api.whatsapp.com/send?phone=612678888&amp;text=My%20Message" style="background-color:#25D366;color:#fff" target="_self" rel="noopener noreferrer">Chat on WhatsApp</a></div>
<!-- /wp:jetpack/whatsapp-button --></div>
<!-- /wp:jetpack/send-a-message -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Internal dependencies
*/
import { settings } from '../';
import { settings as parentSettings } from '../../';
import runBlockFixtureTests from '../../../../shared/test/block-fixtures';

// Need to include all the blocks involved in rendering this block.
// The main block should be the first in the array.
const blocks = [
{ name: 'jetpack/whatsapp-button', settings },
{ name: 'jetpack/send-a-message', settings: parentSettings },
];

runBlockFixtureTests( 'jetpack/whatsapp-button', blocks, __dirname );
Loading

0 comments on commit 1ee629e

Please sign in to comment.