Skip to content

Commit

Permalink
chore: Use snapshots for #9454 conversion tests (#10166)
Browse files Browse the repository at this point in the history
  • Loading branch information
tofumatt committed Sep 25, 2018
1 parent 6321a99 commit 35bd3ff
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
13 changes: 13 additions & 0 deletions test/e2e/specs/__snapshots__/convert-block-type.test.js.snap
@@ -0,0 +1,13 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Code block should convert to a preformatted block 1`] = `
"<!-- wp:code -->
<pre class=\\"wp-block-code\\"><code>print \\"Hello Dolly!\\"</code></pre>
<!-- /wp:code -->"
`;
exports[`Code block should convert to a preformatted block 2`] = `
"<!-- wp:preformatted -->
<pre class=\\"wp-block-preformatted\\">print \\"Hello Dolly!\\"</pre>
<!-- /wp:preformatted -->"
`;
10 changes: 3 additions & 7 deletions test/e2e/specs/convert-block-type.test.js
Expand Up @@ -19,11 +19,9 @@ describe( 'Code block', () => {

await page.type( '.editor-block-list__block textarea', code );

// Verify the content starts as a Code block.
// Verify the content starts out as a Code block.
const originalPostContent = await getEditedPostContent();
const codeRegex = new RegExp( `<!-- wp:code -->\\s*<pre class="wp-block-code"><code>${ code }<\\/code><\\/pre>\\s*<!-- \\/wp:code -->` );

expect( originalPostContent ).toMatch( codeRegex );
expect( originalPostContent ).toMatchSnapshot();

// Hover over this block to show its toolbar so we can click on the block
// conversion button.
Expand All @@ -37,8 +35,6 @@ describe( 'Code block', () => {

// The content should now be a Preformatted block with no data loss.
const convertedPostContent = await getEditedPostContent();
const preformattedRegex = new RegExp( `<!-- wp:preformatted -->\\s*<pre class="wp-block-preformatted">${ code }<\\/pre>\\s*<!-- \\/wp:preformatted -->` );

expect( convertedPostContent ).toMatch( preformattedRegex );
expect( convertedPostContent ).toMatchSnapshot();
} );
} );

0 comments on commit 35bd3ff

Please sign in to comment.