Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta committed Jun 8, 2021
1 parent 3918f63 commit f5c1f87
Show file tree
Hide file tree
Showing 4 changed files with 354 additions and 298 deletions.
1 change: 1 addition & 0 deletions lib/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,7 @@ public function get_stylesheet( $type = 'all' ) {
* Merge new incoming data.
*
* @param WP_Theme_JSON $incoming Data to merge.
* @param string $origin origin of the incoming data (e.g: core, theme, or user).
*/
public function merge( $incoming, $origin ) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,20 @@ describe( 'global styles renderer', () => {
const tree = {
settings: {
color: {
palette: [
{ name: 'White', slug: 'white', color: 'white' },
{ name: 'Black', slug: 'black', color: 'black' },
],
palette: {
user: [
{
name: 'White',
slug: 'white',
color: 'white',
},
{
name: 'Black',
slug: 'black',
color: 'black',
},
],
},
},
custom: {
'font-primary': 'value',
Expand All @@ -229,18 +239,20 @@ describe( 'global styles renderer', () => {
blocks: {
'core/heading': {
typography: {
fontSizes: [
{
name: 'small',
slug: 'small',
size: '12px',
},
{
name: 'medium',
slug: 'medium',
size: '23px',
},
],
fontSizes: {
theme: [
{
name: 'small',
slug: 'small',
size: '12px',
},
{
name: 'medium',
slug: 'medium',
size: '23px',
},
],
},
},
},
},
Expand All @@ -264,10 +276,20 @@ describe( 'global styles renderer', () => {
const tree = {
settings: {
color: {
palette: [
{ name: 'White', slug: 'white', color: 'white' },
{ name: 'Black', slug: 'black', color: 'black' },
],
palette: {
core: [
{
name: 'White',
slug: 'white',
color: 'white',
},
{
name: 'Black',
slug: 'black',
color: 'black',
},
],
},
},
},
styles: {
Expand Down
207 changes: 105 additions & 102 deletions phpunit/class-wp-theme-json-schema-v0-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,129 +335,132 @@ function test_get_settings() {
function test_get_stylesheet() {
$root_name = WP_Theme_JSON_Schema_V0::ROOT_BLOCK_NAME;
$all_blocks_name = WP_Theme_JSON_Schema_V0::ALL_BLOCKS_NAME;

$theme_json = new WP_Theme_JSON_Gutenberg(
array(
'settings' => array(
$all_blocks_name => array(
'color' => array(
'text' => 'value',
'palette' => array(
array(
'slug' => 'white',
'color' => 'white',
),
array(
'slug' => 'black',
'color' => 'black',
$theme_json = new WP_Theme_JSON_Gutenberg( array() );
$theme_json->merge(
new WP_Theme_JSON_Gutenberg(
array(
'settings' => array(
$all_blocks_name => array(
'color' => array(
'text' => 'value',
'palette' => array(
array(
'slug' => 'white',
'color' => 'white',
),
array(
'slug' => 'black',
'color' => 'black',
),
),
),
),
'typography' => array(
'fontFamilies' => array(
array(
'slug' => 'small',
'fontFamily' => '14px',
'typography' => array(
'fontFamilies' => array(
array(
'slug' => 'small',
'fontFamily' => '14px',
),
array(
'slug' => 'big',
'fontFamily' => '41px',
),
),
array(
'slug' => 'big',
'fontFamily' => '41px',
),
'misc' => 'value',
),
$root_name => array(
'color' => array(
'palette' => array(
array(
'slug' => 'grey',
'color' => 'grey',
),
),
),
),
'misc' => 'value',
),
$root_name => array(
'color' => array(
'palette' => array(
array(
'slug' => 'grey',
'color' => 'grey',
'core/group' => array(
'custom' => array(
'base-font' => 16,
'line-height' => array(
'small' => 1.2,
'medium' => 1.4,
'large' => 1.8,
),
),
),
),
'core/group' => array(
'custom' => array(
'base-font' => 16,
'line-height' => array(
'small' => 1.2,
'medium' => 1.4,
'large' => 1.8,
'styles' => array(
$root_name => array(
'color' => array(
'link' => '#111',
'text' => 'var:preset|color|grey',
),
'misc' => 'value',
),
),
),
'styles' => array(
$root_name => array(
'color' => array(
'link' => '#111',
'text' => 'var:preset|color|grey',
),
'misc' => 'value',
),
'core/group' => array(
'color' => array(
'link' => '#333',
),
'spacing' => array(
'padding' => array(
'top' => '12px',
'bottom' => '24px',
'core/group' => array(
'color' => array(
'link' => '#333',
),
'spacing' => array(
'padding' => array(
'top' => '12px',
'bottom' => '24px',
),
),
),
),
'core/heading/h1' => array(
'color' => array(
'link' => '#111',
),
'typography' => array(
'fontSize' => '1em',
),
),
'core/heading/h2' => array(
'color' => array(
'link' => '#222',
),
'typography' => array(
'fontSize' => '2em',
),
),
'core/post-title/h2' => array(
'color' => array(
'link' => '#222',
),
'typography' => array(
'fontSize' => '2em',
),
),
'core/post-title/h5' => array(
'color' => array(
'link' => '#555',
'core/heading/h1' => array(
'color' => array(
'link' => '#111',
),
'typography' => array(
'fontSize' => '1em',
),
),
'typography' => array(
'fontSize' => '5em',
'core/heading/h2' => array(
'color' => array(
'link' => '#222',
),
'typography' => array(
'fontSize' => '2em',
),
),
),
'core/query-title/h4' => array(
'color' => array(
'link' => '#444',
'core/post-title/h2' => array(
'color' => array(
'link' => '#222',
),
'typography' => array(
'fontSize' => '2em',
),
),
'typography' => array(
'fontSize' => '4em',
'core/post-title/h5' => array(
'color' => array(
'link' => '#555',
),
'typography' => array(
'fontSize' => '5em',
),
),
),
'core/query-title/h5' => array(
'color' => array(
'link' => '#555',
'core/query-title/h4' => array(
'color' => array(
'link' => '#444',
),
'typography' => array(
'fontSize' => '4em',
),
),
'typography' => array(
'fontSize' => '5em',
'core/query-title/h5' => array(
'color' => array(
'link' => '#555',
),
'typography' => array(
'fontSize' => '5em',
),
),
),
),
'misc' => 'value',
)
'misc' => 'value',
)
),
'core'
);

$this->assertEquals(
Expand Down
Loading

0 comments on commit f5c1f87

Please sign in to comment.