Skip to content

Commit

Permalink
Parser: Test full lifecycle of quote-escaped attributes parse
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed May 31, 2018
1 parent 9c55552 commit 218370a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions blocks/api/test/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import {
getBlockTypes,
setUnknownTypeHandlerName,
} from '../registration';
import { createBlock } from '../factory';
import serialize from '../serializer';

describe( 'block parser', () => {
const defaultBlockSettings = {
Expand Down Expand Up @@ -571,5 +573,24 @@ describe( 'block parser', () => {
'core/test-block', 'core/void-block',
] );
} );

it( 'should parse with unicode escaped returned to original representation', () => {
registerBlockType( 'core/code', {
category: 'common',
title: 'Code Block',
attributes: {
content: {
type: 'string',
},
},
save: ( { attributes } ) => attributes.content,
} );

const content = '$foo = "My \"escaped\" text.";';
const block = createBlock( 'core/code', { content } );
const serialized = serialize( block );
const parsed = parse( serialized );
expect( parsed[ 0 ].attributes.content ).toBe( content );
} );
} );
} );

0 comments on commit 218370a

Please sign in to comment.