Skip to content

Commit

Permalink
Modify the settings object immutably
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnajdr committed Nov 3, 2022
1 parent a42cdcc commit 280fccc
Showing 1 changed file with 50 additions and 41 deletions.
91 changes: 50 additions & 41 deletions packages/e2e-tests/specs/editor/various/font-size-picker.test.js
Expand Up @@ -102,50 +102,59 @@ describe( 'Font Size Picker', () => {
describe( 'More font sizes', () => {
beforeEach( async () => {
await page.evaluate( () => {
// set a deep `path[]` property in object `obj` to `value`, immutably
function setDeep( obj, path, value ) {
function doSet( o, i ) {
if ( i < path.length ) {
const key = path[ i ];
return { ...o, [ key ]: doSet( o[ key ], i + 1 ) };
}
return value;
}
return doSet( obj, 0 );
}

wp.data.dispatch( 'core/block-editor' ).updateSettings(
// eslint-disable-next-line no-undef
lodash.merge(
setDeep(
wp.data.select( 'core/block-editor' ).getSettings(),
{
__experimentalFeatures: {
typography: {
fontSizes: {
default: [
{
name: 'Tiny',
slug: 'tiny',
size: '11px',
},
{
name: 'Small',
slug: 'small',
size: '13px',
},
{
name: 'Medium',
slug: 'medium',
size: '20px',
},
{
name: 'Large',
slug: 'large',
size: '36px',
},
{
name: 'Extra Large',
slug: 'x-large',
size: '42px',
},
{
name: 'Huge',
slug: 'huge',
size: '48px',
},
],
},
},
[
'__experimentalFeatures',
'typography',
'fontSizes',
'default',
],
[
{
name: 'Tiny',
slug: 'tiny',
size: '11px',
},
}
{
name: 'Small',
slug: 'small',
size: '13px',
},
{
name: 'Medium',
slug: 'medium',
size: '20px',
},
{
name: 'Large',
slug: 'large',
size: '36px',
},
{
name: 'Extra Large',
slug: 'x-large',
size: '42px',
},
{
name: 'Huge',
slug: 'huge',
size: '48px',
},
]
)
);
} );
Expand Down

0 comments on commit 280fccc

Please sign in to comment.