diff --git a/packages/block-editor/src/hooks/test/style.js b/packages/block-editor/src/hooks/test/style.js index ca0175bca18abd..40cc8f49c59f57 100644 --- a/packages/block-editor/src/hooks/test/style.js +++ b/packages/block-editor/src/hooks/test/style.js @@ -126,6 +126,7 @@ describe( 'addSaveProps', () => { title: 'block title', supports: { spacing: { padding: true }, + color: { gradients: true, text: true }, typography: { fontSize: true, __experimentalTextTransform: true, @@ -134,15 +135,22 @@ describe( 'addSaveProps', () => { }, }; - const applySkipSerialization = ( skipSerialization ) => { + const applySkipSerialization = ( features ) => { const updatedSettings = { ...blockSettings }; - updatedSettings.supports.typography.__experimentalSkipSerialization = skipSerialization; - + Object.keys( features ).forEach( ( key ) => { + updatedSettings.supports[ key ].__experimentalSkipSerialization = + features[ key ]; + } ); return updatedSettings; }; const attributes = { style: { + color: { + text: '#d92828', + gradient: + 'linear-gradient(135deg,rgb(6,147,227) 0%,rgb(223,13,13) 46%,rgb(155,81,224) 100%)', + }, spacing: { padding: '10px' }, typography: { fontSize: '1rem', @@ -156,6 +164,9 @@ describe( 'addSaveProps', () => { const extraProps = addSaveProps( {}, blockSettings, attributes ); expect( extraProps.style ).toEqual( { + background: + 'linear-gradient(135deg,rgb(6,147,227) 0%,rgb(223,13,13) 46%,rgb(155,81,224) 100%)', + color: '#d92828', padding: '10px', fontSize: '1rem', textDecoration: 'underline', @@ -164,20 +175,28 @@ describe( 'addSaveProps', () => { } ); it( 'should skip serialization of entire feature set if flag is true', () => { - const settings = applySkipSerialization( true ); + const settings = applySkipSerialization( { + typography: true, + } ); const extraProps = addSaveProps( {}, settings, attributes ); - expect( extraProps.style ).toEqual( { padding: '10px' } ); + expect( extraProps.style ).toEqual( { + background: + 'linear-gradient(135deg,rgb(6,147,227) 0%,rgb(223,13,13) 46%,rgb(155,81,224) 100%)', + color: '#d92828', + padding: '10px', + } ); } ); it( 'should skip serialization of individual features if flag is an array', () => { - const settings = applySkipSerialization( [ - 'textDecoration', - 'textTransform', - ] ); + const settings = applySkipSerialization( { + color: [ 'gradient' ], + typography: [ 'textDecoration', 'textTransform' ], + } ); const extraProps = addSaveProps( {}, settings, attributes ); expect( extraProps.style ).toEqual( { + color: '#d92828', padding: '10px', fontSize: '1rem', } );