-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Blocks: Add regression check for block edit using snapshot testing (#…
- Loading branch information
Showing
43 changed files
with
975 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`core/audio block edit matches snapshot 1`] = ` | ||
<div | ||
class="components-placeholder wp-block-audio" | ||
> | ||
<div | ||
class="components-placeholder__label" | ||
> | ||
<svg | ||
aria-hidden="true" | ||
class="dashicon dashicons-media-audio" | ||
focusable="false" | ||
height="20" | ||
role="img" | ||
viewBox="0 0 20 20" | ||
width="20" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path | ||
d="M12 2l4 4v12H4V2h8zm0 4h3l-3-3v3zm1 7.26V8.09c0-.11-.04-.21-.12-.29-.07-.08-.16-.11-.27-.1 0 0-3.97.71-4.25.78C8.07 8.54 8 8.8 8 9v3.37c-.2-.09-.42-.07-.6-.07-.38 0-.7.13-.96.39-.26.27-.4.58-.4.96 0 .37.14.69.4.95.26.27.58.4.96.4.34 0 .7-.04.96-.26.26-.23.64-.65.64-1.12V10.3l3-.6V12c-.67-.2-1.17.04-1.44.31-.26.26-.39.58-.39.95 0 .38.13.69.39.96.27.26.71.39 1.08.39.38 0 .7-.13.96-.39.26-.27.4-.58.4-.96z" | ||
/> | ||
</svg> | ||
Audio | ||
</div> | ||
<div | ||
class="components-placeholder__instructions" | ||
> | ||
Select an audio file from your library, or upload a new one: | ||
</div> | ||
<div | ||
class="components-placeholder__fieldset" | ||
> | ||
<form> | ||
<input | ||
class="components-placeholder__input" | ||
placeholder="Enter URL of audio file here…" | ||
type="url" | ||
value="" | ||
/> | ||
<button | ||
class="components-button button button-large" | ||
type="submit" | ||
> | ||
Use URL | ||
</button> | ||
</form> | ||
*** Mock(Media upload button) *** | ||
</div> | ||
</div> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import '../'; | ||
import { blockEditRender } from 'blocks/test/helpers'; | ||
|
||
jest.mock( 'blocks/media-upload-button', () => () => '*** Mock(Media upload button) ***' ); | ||
|
||
describe( 'core/audio', () => { | ||
test( 'block edit matches snapshot', () => { | ||
const wrapper = blockEditRender( 'core/audio' ); | ||
|
||
expect( wrapper ).toMatchSnapshot(); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`core/button block edit matches snapshot 1`] = ` | ||
<span | ||
class="wp-block-button" | ||
> | ||
<div | ||
class="blocks-editable" | ||
> | ||
<span | ||
aria-label="Add text…" | ||
class="wp-block-button__link blocks-editable__tinymce" | ||
contenteditable="true" | ||
/> | ||
<span | ||
class="blocks-editable__tinymce wp-block-button__link" | ||
> | ||
Add text… | ||
</span> | ||
</div> | ||
</span> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import '../'; | ||
import { blockEditRender } from 'blocks/test/helpers'; | ||
|
||
describe( 'core/button', () => { | ||
test( 'block edit matches snapshot', () => { | ||
const wrapper = blockEditRender( 'core/button' ); | ||
|
||
expect( wrapper ).toMatchSnapshot(); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`core/code block edit matches snapshot 1`] = ` | ||
<div | ||
class="wp-block-code" | ||
> | ||
<textarea | ||
aria-label="Code" | ||
placeholder="Write code…" | ||
rows="1" | ||
/> | ||
</div> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import '../'; | ||
import { blockEditRender } from 'blocks/test/helpers'; | ||
|
||
describe( 'core/code', () => { | ||
test( 'block edit matches snapshot', () => { | ||
const wrapper = blockEditRender( 'core/code' ); | ||
|
||
expect( wrapper ).toMatchSnapshot(); | ||
} ); | ||
} ); |
93 changes: 93 additions & 0 deletions
93
blocks/library/cover-image/test/__snapshots__/index.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`core/cover-image block edit matches snapshot 1`] = ` | ||
<div | ||
class="components-placeholder wp-block-cover-image" | ||
> | ||
<div | ||
class="components-placeholder__label" | ||
> | ||
<svg | ||
aria-hidden="true" | ||
class="dashicon dashicons-format-image" | ||
focusable="false" | ||
height="20" | ||
role="img" | ||
viewBox="0 0 20 20" | ||
width="20" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path | ||
d="M2.25 1h15.5c.69 0 1.25.56 1.25 1.25v15.5c0 .69-.56 1.25-1.25 1.25H2.25C1.56 19 1 18.44 1 17.75V2.25C1 1.56 1.56 1 2.25 1zM17 17V3H3v14h14zM10 6c0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2 2-.9 2-2zm3 5s0-6 3-6v10c0 .55-.45 1-1 1H5c-.55 0-1-.45-1-1V8c2 0 3 4 3 4s1-3 3-3 3 2 3 2z" | ||
/> | ||
</svg> | ||
Cover Image | ||
</div> | ||
<div | ||
class="components-placeholder__instructions" | ||
> | ||
Drag image here or add from media library | ||
</div> | ||
<div | ||
class="components-placeholder__fieldset" | ||
> | ||
<div | ||
class="components-drop-zone" | ||
> | ||
<div | ||
class="components-drop-zone__content" | ||
> | ||
<svg | ||
aria-hidden="true" | ||
class="dashicon dashicons-upload components-drop-zone__content-icon" | ||
focusable="false" | ||
height="40" | ||
role="img" | ||
viewBox="0 0 20 20" | ||
width="40" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path | ||
d="M8 14V8H5l5-6 5 6h-3v6H8zm-2 2v-6H4v8h12.01v-8H14v6H6z" | ||
/> | ||
</svg> | ||
<span | ||
class="components-drop-zone__content-text" | ||
> | ||
Drop files to upload | ||
</span> | ||
</div> | ||
</div> | ||
<div | ||
class="components-form-file-upload" | ||
> | ||
<button | ||
class="components-button components-icon-button wp-block-image__upload-button button button-large" | ||
type="button" | ||
> | ||
<svg | ||
aria-hidden="true" | ||
class="dashicon dashicons-upload" | ||
focusable="false" | ||
height="20" | ||
role="img" | ||
viewBox="0 0 20 20" | ||
width="20" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path | ||
d="M8 14V8H5l5-6 5 6h-3v6H8zm-2 2v-6H4v8h12.01v-8H14v6H6z" | ||
/> | ||
</svg> | ||
Upload | ||
</button> | ||
<input | ||
accept="image/*" | ||
style="display:none" | ||
type="file" | ||
/> | ||
</div> | ||
*** Mock(Media upload button) *** | ||
</div> | ||
</div> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import '../'; | ||
import { blockEditRender } from 'blocks/test/helpers'; | ||
|
||
jest.mock( 'blocks/media-upload-button', () => () => '*** Mock(Media upload button) ***' ); | ||
|
||
describe( 'core/cover-image', () => { | ||
test( 'block edit matches snapshot', () => { | ||
const wrapper = blockEditRender( 'core/cover-image' ); | ||
|
||
expect( wrapper ).toMatchSnapshot(); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`core/embed block edit matches snapshot 1`] = ` | ||
<div | ||
class="components-placeholder wp-block-embed" | ||
> | ||
<div | ||
class="components-placeholder__label" | ||
> | ||
<svg | ||
aria-hidden="true" | ||
class="dashicon dashicons-embed-generic" | ||
focusable="false" | ||
height="20" | ||
role="img" | ||
viewBox="0 0 20 20" | ||
width="20" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path | ||
d="M17 4H3c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-3 6.5L12.5 12l1.5 1.5V15l-3-3 3-3v1.5zm1 4.5v-1.5l1.5-1.5-1.5-1.5V9l3 3-3 3z" | ||
/> | ||
</svg> | ||
Embed URL | ||
</div> | ||
<div | ||
class="components-placeholder__fieldset" | ||
> | ||
<form> | ||
<input | ||
aria-label="Embed URL" | ||
class="components-placeholder__input" | ||
placeholder="Enter URL to embed here…" | ||
type="url" | ||
value="" | ||
/> | ||
<button | ||
class="components-button button button-large" | ||
type="submit" | ||
> | ||
Embed | ||
</button> | ||
</form> | ||
</div> | ||
</div> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import '../'; | ||
import { blockEditRender } from 'blocks/test/helpers'; | ||
|
||
describe( 'core/embed', () => { | ||
test( 'block edit matches snapshot', () => { | ||
const wrapper = blockEditRender( 'core/embed' ); | ||
|
||
expect( wrapper ).toMatchSnapshot(); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`core/freeform block edit matches snapshot 1`] = ` | ||
Array [ | ||
<div | ||
class="freeform-toolbar" | ||
id="undefined-toolbar" | ||
style="display:none" | ||
/>, | ||
<div | ||
class="wp-block-freeform blocks-editable__tinymce" | ||
/>, | ||
] | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import '../'; | ||
import { blockEditRender } from 'blocks/test/helpers'; | ||
|
||
describe( 'core/freeform', () => { | ||
test( 'block edit matches snapshot', () => { | ||
const wrapper = blockEditRender( 'core/freeform' ); | ||
|
||
expect( wrapper ).toMatchSnapshot(); | ||
} ); | ||
} ); |
Oops, something went wrong.