Skip to content

Commit

Permalink
Use createBlock to define default attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Jul 29, 2017
1 parent 35f81dd commit d6c8fd4
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions blocks/api/test/serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import serialize, {
serializeAttributes,
} from '../serializer';
import { getBlockTypes, registerBlockType, unregisterBlockType } from '../registration';
import { createBlock } from '../';

describe( 'block serializer', () => {
afterEach( () => {
Expand Down Expand Up @@ -195,20 +196,15 @@ describe( 'block serializer', () => {
},
};
registerBlockType( 'core/test-block', blockType );
const blockList = [
{
name: 'core/test-block',
attributes: {
foo: false,
content: 'Ribs & Chicken',
stuff: 'left & right -- but <not>',
},
isValid: true,
},
];

const block = createBlock( 'core/test-block', {
foo: false,
content: 'Ribs & Chicken',
stuff: 'left & right -- but <not>',
} );
const expectedPostContent = '<!-- wp:core/test-block {"foo":false,"stuff":"left \\u0026 right \\u002d\\u002d but \\u003cnot\\u003e"} -->\n<p class="wp-block-test-block">Ribs & Chicken</p>\n<!-- /wp:core/test-block -->';

expect( serialize( blockList ) ).toEqual( expectedPostContent );
expect( serialize( [ block ] ) ).toEqual( expectedPostContent );
} );
} );
} );

0 comments on commit d6c8fd4

Please sign in to comment.