Skip to content

Commit

Permalink
Add tests for JS changes
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewserong committed Oct 7, 2022
1 parent 507c5b3 commit 40e7fb7
Showing 1 changed file with 57 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -711,10 +711,11 @@ describe( 'global styles renderer', () => {
},
typography: {
fontFamily: 'sans-serif',
fontSize: '14px',
},
};

it( 'Should output padding variables and other properties if useRootPaddingAwareAlignments is enabled', () => {
it( 'should output padding variables and other properties if useRootPaddingAwareAlignments is enabled', () => {
expect(
getStylesDeclarations( blockStyles, 'body', true )
).toEqual( [
Expand All @@ -724,10 +725,11 @@ describe( 'global styles renderer', () => {
'--wp--style--root--padding-left: 33px',
'background-color: var(--wp--preset--color--light-green-cyan)',
'font-family: sans-serif',
'font-size: 14px',
] );
} );

it( 'Should output padding and other properties if useRootPaddingAwareAlignments is disabled', () => {
it( 'should output padding and other properties if useRootPaddingAwareAlignments is disabled', () => {
expect(
getStylesDeclarations( blockStyles, 'body', false )
).toEqual( [
Expand All @@ -737,10 +739,11 @@ describe( 'global styles renderer', () => {
'padding-bottom: 33px',
'padding-left: 33px',
'font-family: sans-serif',
'font-size: 14px',
] );
} );

it( 'Should not output padding variables if selector is not root', () => {
it( 'should not output padding variables if selector is not root', () => {
expect(
getStylesDeclarations(
blockStyles,
Expand All @@ -754,6 +757,57 @@ describe( 'global styles renderer', () => {
'padding-bottom: 33px',
'padding-left: 33px',
'font-family: sans-serif',
'font-size: 14px',
] );
} );

it( 'should output clamp values for font-size when fluid typography is enabled', () => {
expect(
getStylesDeclarations(
blockStyles,
'.wp-block-site-title',
true,
{
settings: {
typography: {
fluid: true,
},
},
}
)
).toEqual( [
'background-color: var(--wp--preset--color--light-green-cyan)',
'padding-top: 33px',
'padding-right: 33px',
'padding-bottom: 33px',
'padding-left: 33px',
'font-family: sans-serif',
'font-size: clamp(10.5px, 0.65625rem + ((1vw - 7.68px) * 1.262), 21px)',
] );
} );

it( 'should output direct values for font-size when fluid typography is disabled', () => {
expect(
getStylesDeclarations(
blockStyles,
'.wp-block-site-title',
true,
{
settings: {
typography: {
fluid: false,
},
},
}
)
).toEqual( [
'background-color: var(--wp--preset--color--light-green-cyan)',
'padding-top: 33px',
'padding-right: 33px',
'padding-bottom: 33px',
'padding-left: 33px',
'font-family: sans-serif',
'font-size: 14px',
] );
} );
} );
Expand Down

0 comments on commit 40e7fb7

Please sign in to comment.