Skip to content

Commit

Permalink
de-abstract tests for better messaging on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
dmsnell committed Oct 30, 2018
1 parent cfdc3a3 commit 13cdfdd
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions packages/block-serialization-spec-parser/shared-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,18 @@ export const testParser = ( parse ) => () => {
} );

describe( 'blockMarkers', () => {
test( 'adds empty block markers when no inner blocks exist', () => [
'<!-- wp:void /-->',
'<!-- wp:block --><!-- /wp:block -->',
'<!-- wp:block -->with content<!-- /wp:block -->',
].forEach( ( document ) => expect( parse( document )[ 0 ] ).toHaveProperty( 'blockMarkers', [] ) ) );

test( 'adds block markers for inner blocks', () => [
[ '<!-- wp:block --><!-- wp:void /--><!-- /wp:block -->', [ 0 ] ],
[ '<!-- wp:block -->aa<!-- wp:void /-->bb<!-- /wp:block -->', [ 2 ] ],
[ '<!-- wp:block -->aa<!-- wp:inner -->bb<!-- /wp:inner -->cc<!-- /wp:block -->', [ 2 ] ],
[ '<!-- wp:block --><!-- wp:start /-->aa<!-- wp:inner -->bb<!-- /wp:inner -->cc<!-- wp:end /--><!-- /wp:block -->', [ 0, 2, 4 ] ],
].forEach( ( [ document, markers ] ) => expect( parse( document )[ 0 ] ).toHaveProperty( 'blockMarkers', markers ) ) );
test( 'adds empty block markers when no inner blocks exist', () => {
expect( parse( '<!-- wp:void /-->' )[ 0 ] ).toHaveProperty( 'blockMarkers', [] );
expect( parse( '<!-- wp:block --><!-- /wp:block -->' )[ 0 ] ).toHaveProperty( 'blockMarkers', [] );
expect( parse( '<!-- wp:block -->with content<!-- /wp:block -->' )[ 0 ] ).toHaveProperty( 'blockMarkers', [] );
} );

test( 'adds block markers for inner blocks', () => {
expect( parse( '<!-- wp:block --><!-- wp:void /--><!-- /wp:block -->' )[ 0 ] ).toHaveProperty( 'blockMarkers', [ 0 ] );
expect( parse( '<!-- wp:block -->aa<!-- wp:void /-->bb<!-- /wp:block -->' )[ 0 ] ).toHaveProperty( 'blockMarkers', [ 2 ] );
expect( parse( '<!-- wp:block -->aa<!-- wp:inner -->bb<!-- /wp:inner -->cc<!-- /wp:block -->' )[ 0 ] ).toHaveProperty( 'blockMarkers', [ 2 ] );
expect( parse( '<!-- wp:block --><!-- wp:start /-->aa<!-- wp:inner -->bb<!-- /wp:inner -->cc<!-- wp:end /--><!-- /wp:block -->' )[ 0 ] ).toHaveProperty( 'blockMarkers', [ 0, 2, 4 ] );
} );

test( 'block markers report UTF-8 encoding byte-length', () => {
const run = ( c ) => parse( `<!-- wp:block -->${ c }<!-- wp:void /--><!-- /wp:block -->` )[ 0 ];
Expand Down

0 comments on commit 13cdfdd

Please sign in to comment.