-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve Dynamic Separator block stability through transforms testing (#…
- Loading branch information
1 parent
5c11939
commit 79840ce
Showing
1 changed file
with
49 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,49 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { registerCoreBlocks } from '@wordpress/block-library'; | ||
import { registerBlockType, createBlock, switchToBlockType } from '@wordpress/blocks'; | ||
|
||
registerCoreBlocks(); | ||
|
||
/** | ||
* Internal dependencies. | ||
*/ | ||
import { name, settings } from '../index'; | ||
|
||
describe( 'coblocks/dynamic-separator transforms', () => { | ||
beforeAll( () => { | ||
// Register the block. | ||
registerBlockType( name, { category: 'common', ...settings } ); | ||
} ); | ||
|
||
it( 'should transform from core/spacer block', () => { | ||
const coreSpacer = createBlock( 'core/spacer', { height: 200 } ); | ||
const transformed = switchToBlockType( coreSpacer, name ); | ||
|
||
expect( transformed[ 0 ].isValid ).toBe( true ); | ||
expect( transformed[ 0 ].attributes.height ).toBe( 200 ); | ||
} ); | ||
|
||
it( 'should transform from core/separator block', () => { | ||
const coreSeparator = createBlock( 'core/separator' ); | ||
|
||
const transformed = switchToBlockType( coreSeparator, name ); | ||
expect( transformed[ 0 ].isValid ).toBe( true ); | ||
} ); | ||
|
||
it( 'should transform to core/spacer block', () => { | ||
const block = createBlock( name, { height: 200 } ); | ||
const transformed = switchToBlockType( block, 'core/spacer' ); | ||
|
||
expect( transformed[ 0 ].isValid ).toBe( true ); | ||
expect( transformed[ 0 ].attributes.height ).toBe( 200 ); | ||
} ); | ||
|
||
it( 'should transform to core/separator block', () => { | ||
const block = createBlock( name ); | ||
const transformed = switchToBlockType( block, 'core/separator' ); | ||
|
||
expect( transformed[ 0 ].isValid ).toBe( true ); | ||
} ); | ||
} ); |