Skip to content

Commit

Permalink
Add test for customCSS in get_stylesheet
Browse files Browse the repository at this point in the history
  • Loading branch information
glendaviesnz committed Dec 5, 2022
1 parent d312776 commit 7291aa1
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions phpunit/class-wp-theme-json-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -1453,4 +1453,24 @@ public function test_update_separator_declarations() {
$this->assertEquals( $expected, $stylesheet );

}

public function test_get_stylesheet_handles_custom_css() {
$theme_json = new WP_Theme_JSON_Gutenberg(
array(
'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA,
'styles' => array(
'css' => 'body { color:purple; }',
),
)
);

$base_styles = 'body { margin: 0;}.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }';

$custom_css = 'body { color:purple; }';

$expected = $base_styles . $custom_css;

$this->assertEquals( $expected, $theme_json->get_stylesheet() );
$this->assertEquals( $custom_css, $theme_json->get_stylesheet( array( 'customCSS' ) ) );
}
}

0 comments on commit 7291aa1

Please sign in to comment.