Skip to content

Commit

Permalink
Add a second test case with two shortcode instances
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbachhuber committed Jul 9, 2018
1 parent 45212b8 commit 77fb88d
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion blocks/api/raw-handling/test/shortcode-converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,31 @@ describe( 'segmentHTMLToShortcodeBlock', () => {
<p>Bar</p>` );
} );

it( 'should convert multiple instances of the same shortcode', () => {
it( 'should convert two instances of the same shortcode', () => {
const original = `<p>[foo one]</p>
<p>[foo two]</p>`;

const transformed = segmentHTMLToShortcodeBlock( original, 0 );
expect( transformed[ 0 ] ).toEqual( '<p>' );
const firstExpectedBlock = createBlock( 'core/shortcode', {
text: '[foo one]',
} );
// uid will always be random.
firstExpectedBlock.uid = transformed[ 1 ].uid;
expect( transformed[ 1 ] ).toEqual( firstExpectedBlock );
expect( transformed[ 2 ] ).toEqual( `</p>
<p>` );
const secondExpectedBlock = createBlock( 'core/shortcode', {
text: '[foo two]',
} );
// uid will always be random.
secondExpectedBlock.uid = transformed[ 3 ].uid;
expect( transformed[ 3 ] ).toEqual( secondExpectedBlock );
expect( transformed[ 4 ] ).toEqual( '</p>' );
expect( transformed ).toHaveLength( 5 );
} );

it( 'should convert four instances of the same shortcode', () => {
const original = `<p>[foo one]</p>
<p>[foo two]</p>
<p>[foo three]</p>
Expand Down

0 comments on commit 77fb88d

Please sign in to comment.