Skip to content

Commit

Permalink
Add test for iframe
Browse files Browse the repository at this point in the history
  • Loading branch information
SantosGuillamot committed Mar 12, 2024
1 parent 3c2a87e commit 155fe30
Showing 1 changed file with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* @group interactivity-api
*/
class Tests_Interactivity_API_Functions extends WP_UnitTestCase {
class Tests_Interactivity_API_wpInteractivityAPIFunctions extends WP_UnitTestCase {
/**
* Set up.
*/
Expand Down Expand Up @@ -390,4 +390,31 @@ public function test_wp_interactivity_data_wp_context_with_json_flags() {
$this->assertEquals( 'data-wp-context=\'{"quot":"\u0022baz\u0022"}\'', wp_interactivity_data_wp_context( array( 'quot' => '"baz"' ) ) );
$this->assertEquals( 'data-wp-context=\'{"amp":"T\u0026T"}\'', wp_interactivity_data_wp_context( array( 'amp' => 'T&T' ) ) );
}

/**
* Tests that directives processing of tags that don't visit closer tag work.
*
* @ticket 60746
*
* @covers ::wp_interactivity_process_directives_of_interactive_blocks
*/
public function test_process_directives_in_tags_that_dont_visit_closer_tag() {
register_block_type(
'test/custom-directive-block',
array(
'render_callback' => function () {
return '<iframe data-wp-interactive="nameSpace" ' . wp_interactivity_data_wp_context( array( 'text' => 'test' ) ) . ' data-wp-class--test="context.text" src="1"></iframe>';
},
'supports' => array(
'interactivity' => true,
),
)
);
$post_content = '<!-- wp:test/custom-directive-block /-->';
$processed_content = do_blocks( $post_content );
$processor = new WP_HTML_Tag_Processor( $processed_content );
$processor->next_tag( array( 'class_name' => 'test' ) );
unregister_block_type( 'test/custom-directive-block' );
$this->assertEquals( '1', $processor->get_attribute( 'src' ) );
}
}

0 comments on commit 155fe30

Please sign in to comment.