diff --git a/packages/block-library/src/audio/test/__snapshots__/edit.native.js.snap b/packages/block-library/src/audio/test/__snapshots__/edit.native.js.snap new file mode 100644 index 00000000000000..b11b526d43565b --- /dev/null +++ b/packages/block-library/src/audio/test/__snapshots__/edit.native.js.snap @@ -0,0 +1,376 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Audio block renders audio block error state without crashing 1`] = ` + + + + Modal + + + Svg + + + + 59IrU0WJtq + + + Svg + + Failed to insert audio file. Please tap for options. + + + + + + + + + + + + + +`; + +exports[`Audio block renders audio file without crashing 1`] = ` + + + + Modal + + + Svg + + + + 59IrU0WJtq + + + + MP3 audio file + + + + + + OPEN + + + + + + + + + + + + +`; + +exports[`Audio block renders placeholder without crashing 1`] = ` + + + + Modal + + + Svg + + + + Audio + + + ADD AUDIO + + + + +`; diff --git a/packages/block-library/src/audio/test/edit.native.js b/packages/block-library/src/audio/test/edit.native.js new file mode 100644 index 00000000000000..9dee5b1771bf9e --- /dev/null +++ b/packages/block-library/src/audio/test/edit.native.js @@ -0,0 +1,51 @@ +/** + * External dependencies + */ +import renderer from 'react-test-renderer'; + +/** + * WordPress dependencies + */ +import { MediaUploadProgress } from '@wordpress/block-editor'; + +/** + * Internal dependencies + */ +import AudioEdit from '../edit.native.js'; + +const getTestComponentWithContent = ( attributes = {} ) => { + return renderer.create( + + ); +}; + +describe( 'Audio block', () => { + it( 'renders placeholder without crashing', () => { + const component = getTestComponentWithContent(); + const rendered = component.toJSON(); + expect( rendered ).toMatchSnapshot(); + } ); + + it( 'renders audio file without crashing', () => { + const component = getTestComponentWithContent( { + src: 'https://cldup.com/59IrU0WJtq.mp3', + id: '1', + } ); + + const rendered = component.toJSON(); + expect( rendered ).toMatchSnapshot(); + } ); + + it( 'renders audio block error state without crashing', () => { + const component = getTestComponentWithContent( { + src: 'https://cldup.com/59IrU0WJtq.mp3', + id: '1', + } ); + + const mediaUpload = component.root.findByType( MediaUploadProgress ); + mediaUpload.instance.finishMediaUploadWithFailure( { mediaId: -1 } ); + + const rendered = component.toJSON(); + expect( rendered ).toMatchSnapshot(); + } ); +} );