Skip to content

Commit

Permalink
Unit test for deprecated useSetting
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnajdr committed Oct 19, 2023
1 parent 9ebf699 commit 8a312be
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion packages/block-editor/src/components/use-settings/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { useEffect } from '@wordpress/element';
/**
* Internal dependencies
*/
import { useSettings } from '..';
import { useSettings, useSetting } from '..';
import * as BlockEditContext from '../../block-edit/context';

// Mock useSelect() functions used by useSettings()
Expand Down Expand Up @@ -116,4 +116,26 @@ describe( 'useSettings', () => {
'test/useSetting.before'
);
} );

it( 'supports also the deprecated useSetting function', () => {
mockSettings( {
blocks: {
'core/test-block': {
layout: {
contentSize: '840px',
},
},
},
} );

mockCurrentBlockContext( {
name: 'core/test-block',
} );

const result = runHook( () => useSetting( 'layout.contentSize' ) );
expect( result ).toBe( '840px' );
expect( console ).toHaveWarnedWith(
'wp.blockEditor.useSetting is deprecated since version 6.4. Please use wp.blockEditor.useSettings instead.'
);
} );
} );

0 comments on commit 8a312be

Please sign in to comment.