-
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 Features block stability through transforms testing (#1189)
* add features block transform tests * remove extra imports
- Loading branch information
1 parent
79840ce
commit 9acc7b2
Showing
1 changed file
with
35 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,35 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { registerBlockType } from '@wordpress/blocks'; | ||
|
||
/** | ||
* Internal dependencies. | ||
*/ | ||
import * as helpers from '../../../../.dev/tests/jest/helpers'; | ||
import { name, settings } from '../index'; | ||
|
||
describe( 'coblocks/features transforms', () => { | ||
beforeAll( () => { | ||
// Register the block. | ||
registerBlockType( name, { category: 'common', ...settings } ); | ||
} ); | ||
|
||
it( 'should transform when :feature prefix is seen', () => { | ||
const block = helpers.performPrefixTransformation( name, ':feature', ':feature' ); | ||
expect( block.isValid ).toBe( true ); | ||
expect( block.name ).toBe( name ); | ||
expect( block.attributes.columns ).toBe( 1 ); // should be single column. | ||
} ); | ||
|
||
// Should allow transform when prefixed with 1-3 colons. | ||
for ( let i = 1; i <= 3; i++ ) { | ||
const prefix = Array( i + 1 ).join( ':' ) + 'features'; | ||
it( `should transform when ${ prefix } prefix is seen`, () => { | ||
const block = helpers.performPrefixTransformation( name, prefix, prefix ); | ||
expect( block.isValid ).toBe( true ); | ||
expect( block.name ).toBe( name ); | ||
expect( block.attributes.columns ).toBe( Math.max( i, 2 ) ); // should be 2 minimum columns or 3 max. | ||
} ); | ||
} | ||
} ); |