Skip to content

Commit

Permalink
Improve Dynamic Separator block stability through transforms testing (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyLedesma authored and jrtashjian committed Dec 11, 2019
1 parent 5c11939 commit 79840ce
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/blocks/dynamic-separator/test/transforms.spec.js
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 );
} );
} );

0 comments on commit 79840ce

Please sign in to comment.