Skip to content

Commit

Permalink
fix: Add a lock attribue test
Browse files Browse the repository at this point in the history
  • Loading branch information
ashutoshgautams committed Sep 23, 2024
1 parent 110103c commit 33d60f5
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions tests/unit/CoreHeadingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -434,4 +434,60 @@ public function test_retrieve_core_heading_with_gradient() {
$attributes
);
}

/**
* Test retrieval of core/heading block with lock attribute.
*
* @return void
*/
public function test_retrieve_core_heading_with_lock() {
$block_content = '
<!-- wp:heading {"lock":{"move":true,"remove":true},"level":2} -->
<h2 class="wp-block-heading">Locked Heading</h2>
<!-- /wp:heading>
';

wp_update_post(
[
'ID' => $this->post_id,
'post_content' => $block_content,
]
);

$actual = graphql(
[
'query' => $this->query(),
'variables' => [ 'id' => $this->post_id ],
]
);

$block = $actual['data']['post']['editorBlocks'][0];
$attributes = $block['attributes'];

$this->assertEquals(
[
'align' => null,
'anchor' => null,
'backgroundColor' => null,
'className' => null,
'content' => 'Locked Heading',
'cssClassName' => 'wp-block-heading',
'fontFamily' => null,
'fontSize' => null,
'gradient' => null,
'level' => 2.0,
'lock' => wp_json_encode(
[
'move' => true,
'remove' => true,
]
),
'placeholder' => null,
'style' => null,
'textAlign' => null,
'textColor' => null,
],
$attributes
);
}
}

0 comments on commit 33d60f5

Please sign in to comment.