-
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.
- Loading branch information
1 parent
37d44e8
commit 06f5975
Showing
4 changed files
with
122 additions
and
30 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
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
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,69 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { getOverridableAttributes } from '../'; | ||
import { PARTIAL_SYNCING_SUPPORTED_BLOCKS } from '../../constants'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { createBlock } from '@wordpress/blocks'; | ||
import { registerCoreBlocks } from '@wordpress/block-library'; | ||
|
||
describe( 'getOverridableAttributes', () => { | ||
beforeAll( () => { | ||
registerCoreBlocks(); | ||
} ); | ||
|
||
it( 'should return an array of overridable attributes', () => { | ||
const block = createBlock( 'core/paragraph', { | ||
metadata: { | ||
bindings: { | ||
content: { source: 'core/pattern-overrides' }, | ||
}, | ||
}, | ||
} ); | ||
|
||
const attributes = getOverridableAttributes( block ); | ||
|
||
expect( attributes ).toEqual( [ 'content' ] ); | ||
} ); | ||
|
||
it( 'should return the default list for core blocks', () => { | ||
const block = createBlock( 'core/image', { | ||
metadata: { | ||
bindings: { | ||
__default: { source: 'core/pattern-overrides' }, | ||
}, | ||
}, | ||
} ); | ||
|
||
const attributes = getOverridableAttributes( block ); | ||
|
||
expect( attributes ).toEqual( | ||
PARTIAL_SYNCING_SUPPORTED_BLOCKS[ 'core/image' ] | ||
); | ||
} ); | ||
|
||
it( 'should allow overrides of the default list', () => { | ||
const block = createBlock( 'core/image', { | ||
metadata: { | ||
bindings: { | ||
__default: { source: 'core/pattern-overrides' }, | ||
alt: { source: 'core/post-meta' }, | ||
width: { source: 'core/pattern-overrides' }, | ||
}, | ||
}, | ||
} ); | ||
|
||
const attributes = getOverridableAttributes( block ); | ||
|
||
const defaultAttributes = new Set( | ||
PARTIAL_SYNCING_SUPPORTED_BLOCKS[ 'core/image' ] | ||
); | ||
defaultAttributes.delete( 'alt' ); | ||
defaultAttributes.add( 'width' ); | ||
|
||
expect( attributes ).toEqual( Array.from( defaultAttributes ) ); | ||
} ); | ||
} ); |
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