Skip to content

Commit

Permalink
Video Block: Fix Tests and parsing after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Aug 10, 2017
1 parent 81e617c commit 60001ba
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 5 deletions.
14 changes: 10 additions & 4 deletions blocks/library/video/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import { Placeholder } from '@wordpress/components';
/**
* Internal dependencies
*/
import { registerBlockType, query } from '../../api';
import { registerBlockType, source } from '../../api';
import MediaUploadButton from '../../media-upload-button';
import Editable from '../../editable';

const { attr, children } = query;
const { attr, children } = source;

registerBlockType( 'core/video', {
title: __( 'Video' ),
Expand All @@ -25,8 +25,14 @@ registerBlockType( 'core/video', {
category: 'common',

attributes: {
src: attr( 'video', 'src' ),
caption: children( 'figcaption' ),
src: {
type: 'string',
source: attr( 'video', 'src' ),
},
caption: {
type: 'array',
source: children( 'figcaption' ),
},
},

edit( { attributes, setAttributes, className, focus, setFocus } ) {
Expand Down
3 changes: 3 additions & 0 deletions blocks/test/fixtures/core__video.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!-- wp:core/video -->
<figure class="wp-block-video"><video src="https://awesome-fake.video/file.mp4" controls=""></video></figure>
<!-- /wp:core/video -->
11 changes: 11 additions & 0 deletions blocks/test/fixtures/core__video.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"uid": "_uid_0",
"name": "core/video",
"isValid": true,
"attributes": {
"src": "https://awesome-fake.video/file.mp4",
"caption": []
}
}
]
11 changes: 11 additions & 0 deletions blocks/test/fixtures/core__video.parsed.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"blockName": "core/video",
"attrs": null,
"rawContent": "\n<figure class=\"wp-block-video\"><video src=\"https://awesome-fake.video/file.mp4\" controls=\"\"></video></figure>\n"
},
{
"attrs": {},
"rawContent": "\n"
}
]
3 changes: 3 additions & 0 deletions blocks/test/fixtures/core__video.serialized.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!-- wp:core/video -->
<figure class="wp-block-video"><video controls="" src="https://awesome-fake.video/file.mp4"></video></figure>
<!-- /wp:core/video -->
2 changes: 1 addition & 1 deletion editor/test/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ describe( 'state', () => {
type: 'SETUP_EDITOR',
} );

expect( initial.recentlyUsedBlocks ).toEqual( expect.arrayContaining( [ 'core/test-block', 'core/paragraph' ] ) );
expect( initial.recentlyUsedBlocks ).toEqual( expect.arrayContaining( [ 'core/paragraph' ] ) );
} );
} );
} );

0 comments on commit 60001ba

Please sign in to comment.