Skip to content

Commit

Permalink
chore : use wp_json_encode
Browse files Browse the repository at this point in the history
  • Loading branch information
Ta5r committed Sep 20, 2024
1 parent 1ef90db commit a4c2670
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions tests/unit/CoreQuoteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,6 @@ public function test_retrieve_core_quote_fields_and_attributes() {
* - 'style'
* - 'textColor'
*
* @todo Use `wp_json_encode` for the 'style' attribute to improve accuracy in future tests.
*
* @return void
*/
public function test_retrieve_core_quote_attributes() {
Expand Down Expand Up @@ -207,6 +205,19 @@ public function test_retrieve_core_quote_attributes() {
$this->assertEmpty( $block['parentClientId'], 'There should be no parentClientId' );
$this->assertNotEmpty( $block['renderedHtml'], 'The renderedHtml should be present' );

$style = wp_json_encode(
[
'elements' => [
'heading' => [
'color' => [
'text' => 'var:preset|color|vivid-cyan-blue',
'background' => 'var:preset|color|cyan-bluish-gray',
],
],
],
]
);

// Verify the attributes.
$this->assertEquals(
[
Expand All @@ -218,8 +229,13 @@ public function test_retrieve_core_quote_attributes() {
'fontFamily' => 'body',
'fontSize' => 'small',
'gradient' => 'pale-ocean',
'lock' => '{"move":true,"remove":true}',
'style' => '{"elements":{"heading":{"color":{"text":"var:preset|color|vivid-cyan-blue","background":"var:preset|color|cyan-bluish-gray"}}}}', // @todo : use wp_json_encode here.
'lock' => wp_json_encode(
[
'move' => true,
'remove' => true,
]
),
'style' => $style,
'textColor' => 'vivid-red',
'value' => '',
],
Expand Down

0 comments on commit a4c2670

Please sign in to comment.