From d6d2031c1bdc6a558db601e2ddfc417769cf98bc Mon Sep 17 00:00:00 2001 From: Grzegorz Ziolkowski Date: Fri, 6 Nov 2020 13:27:29 +0100 Subject: [PATCH] Tests: Add fixture for Column deprecation --- .../block-library/src/column/deprecated.js | 8 ++-- .../blocks/core__column__deprecated-1.html | 10 +++++ .../blocks/core__column__deprecated-1.json | 35 +++++++++++++++ .../core__column__deprecated-1.parsed.json | 45 +++++++++++++++++++ ...core__column__deprecated-1.serialized.html | 9 ++++ 5 files changed, 103 insertions(+), 4 deletions(-) create mode 100644 packages/e2e-tests/fixtures/blocks/core__column__deprecated-1.html create mode 100644 packages/e2e-tests/fixtures/blocks/core__column__deprecated-1.json create mode 100644 packages/e2e-tests/fixtures/blocks/core__column__deprecated-1.parsed.json create mode 100644 packages/e2e-tests/fixtures/blocks/core__column__deprecated-1.serialized.html diff --git a/packages/block-library/src/column/deprecated.js b/packages/block-library/src/column/deprecated.js index 52d3f675df299..995927b543a6d 100644 --- a/packages/block-library/src/column/deprecated.js +++ b/packages/block-library/src/column/deprecated.js @@ -20,6 +20,9 @@ const deprecated = [ max: 100, }, }, + isEligible( { width } ) { + return isFinite( width ); + }, migrate( attributes ) { return { ...attributes, @@ -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 (
diff --git a/packages/e2e-tests/fixtures/blocks/core__column__deprecated-1.html b/packages/e2e-tests/fixtures/blocks/core__column__deprecated-1.html new file mode 100644 index 0000000000000..9a91555220e9d --- /dev/null +++ b/packages/e2e-tests/fixtures/blocks/core__column__deprecated-1.html @@ -0,0 +1,10 @@ + +
+ +

Column One, Paragraph One

+ + +

Column One, Paragraph Two

+ +
+ diff --git a/packages/e2e-tests/fixtures/blocks/core__column__deprecated-1.json b/packages/e2e-tests/fixtures/blocks/core__column__deprecated-1.json new file mode 100644 index 0000000000000..84b28da2956a0 --- /dev/null +++ b/packages/e2e-tests/fixtures/blocks/core__column__deprecated-1.json @@ -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": "

Column One, Paragraph One

" + }, + { + "clientId": "_clientId_1", + "name": "core/paragraph", + "isValid": true, + "attributes": { + "content": "Column One, Paragraph Two", + "dropCap": false + }, + "innerBlocks": [], + "originalContent": "

Column One, Paragraph Two

" + } + ], + "originalContent": "
\n\t\n\t\n
" + } +] diff --git a/packages/e2e-tests/fixtures/blocks/core__column__deprecated-1.parsed.json b/packages/e2e-tests/fixtures/blocks/core__column__deprecated-1.parsed.json new file mode 100644 index 0000000000000..050341fdaedb4 --- /dev/null +++ b/packages/e2e-tests/fixtures/blocks/core__column__deprecated-1.parsed.json @@ -0,0 +1,45 @@ +[ + { + "blockName": "core/column", + "attrs": { + "width": 33.33 + }, + "innerBlocks": [ + { + "blockName": "core/paragraph", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n\t

Column One, Paragraph One

\n\t", + "innerContent": [ + "\n\t

Column One, Paragraph One

\n\t" + ] + }, + { + "blockName": "core/paragraph", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n\t

Column One, Paragraph Two

\n\t", + "innerContent": [ + "\n\t

Column One, Paragraph Two

\n\t" + ] + } + ], + "innerHTML": "\n
\n\t\n\t\n
\n", + "innerContent": [ + "\n
\n\t", + null, + "\n\t", + null, + "\n
\n" + ] + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n", + "innerContent": [ + "\n" + ] + } +] diff --git a/packages/e2e-tests/fixtures/blocks/core__column__deprecated-1.serialized.html b/packages/e2e-tests/fixtures/blocks/core__column__deprecated-1.serialized.html new file mode 100644 index 0000000000000..83dd9fc0dd594 --- /dev/null +++ b/packages/e2e-tests/fixtures/blocks/core__column__deprecated-1.serialized.html @@ -0,0 +1,9 @@ + +
+

Column One, Paragraph One

+ + + +

Column One, Paragraph Two

+
+