Skip to content

Commit

Permalink
Tests: Add fixture for Column deprecation (#26774)
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo authored Nov 6, 2020
1 parent 2073c67 commit f66ebf8
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/block-library/src/column/deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ const deprecated = [
max: 100,
},
},
isEligible( { width } ) {
return isFinite( width );
},
migrate( attributes ) {
return {
...attributes,
Expand All @@ -33,10 +36,7 @@ const deprecated = [
[ `is-vertically-aligned-${ verticalAlignment }` ]: verticalAlignment,
} );

let style;
if ( Number.isFinite( width ) ) {
style = { flexBasis: width + '%' };
}
const style = { flexBasis: width + '%' };

return (
<div className={ wrapperClasses } style={ style }>
Expand Down
10 changes: 10 additions & 0 deletions packages/e2e-tests/fixtures/blocks/core__column__deprecated-1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!-- wp:column {"width":33.33} -->
<div class="wp-block-column" style="flex-basis:33.33%">
<!-- wp:paragraph -->
<p>Column One, Paragraph One</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>Column One, Paragraph Two</p>
<!-- /wp:paragraph -->
</div>
<!-- /wp:columns -->
35 changes: 35 additions & 0 deletions packages/e2e-tests/fixtures/blocks/core__column__deprecated-1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[
{
"clientId": "_clientId_0",
"name": "core/column",
"isValid": true,
"attributes": {
"width": "33.33%"
},
"innerBlocks": [
{
"clientId": "_clientId_0",
"name": "core/paragraph",
"isValid": true,
"attributes": {
"content": "Column One, Paragraph One",
"dropCap": false
},
"innerBlocks": [],
"originalContent": "<p>Column One, Paragraph One</p>"
},
{
"clientId": "_clientId_1",
"name": "core/paragraph",
"isValid": true,
"attributes": {
"content": "Column One, Paragraph Two",
"dropCap": false
},
"innerBlocks": [],
"originalContent": "<p>Column One, Paragraph Two</p>"
}
],
"originalContent": "<div class=\"wp-block-column\" style=\"flex-basis:33.33%\">\n\t\n\t\n</div>"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[
{
"blockName": "core/column",
"attrs": {
"width": 33.33
},
"innerBlocks": [
{
"blockName": "core/paragraph",
"attrs": {},
"innerBlocks": [],
"innerHTML": "\n\t<p>Column One, Paragraph One</p>\n\t",
"innerContent": [
"\n\t<p>Column One, Paragraph One</p>\n\t"
]
},
{
"blockName": "core/paragraph",
"attrs": {},
"innerBlocks": [],
"innerHTML": "\n\t<p>Column One, Paragraph Two</p>\n\t",
"innerContent": [
"\n\t<p>Column One, Paragraph Two</p>\n\t"
]
}
],
"innerHTML": "\n<div class=\"wp-block-column\" style=\"flex-basis:33.33%\">\n\t\n\t\n</div>\n",
"innerContent": [
"\n<div class=\"wp-block-column\" style=\"flex-basis:33.33%\">\n\t",
null,
"\n\t",
null,
"\n</div>\n"
]
},
{
"blockName": null,
"attrs": {},
"innerBlocks": [],
"innerHTML": "\n",
"innerContent": [
"\n"
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!-- wp:column {"width":"33.33%"} -->
<div class="wp-block-column" style="flex-basis:33.33%"><!-- wp:paragraph -->
<p>Column One, Paragraph One</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Column One, Paragraph Two</p>
<!-- /wp:paragraph --></div>
<!-- /wp:column -->

0 comments on commit f66ebf8

Please sign in to comment.