Skip to content

Commit bbfc18e

Browse files
committed
Account for detect loader in tests
1 parent 4497b85 commit bbfc18e

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

plugins/optimization-detective/tests/class-optimization-detective-test-helpers.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ static function ( $matches ) {
290290
$text = trim( $text );
291291
if ( 1 === preg_match( '/^(import|const) \w+/', $text, $matches ) ) {
292292
$text = '/* ' . $matches[0] . ' ... */';
293+
} elseif ( 1 === preg_match( '/^\( async function load.+\);$/s', $text ) ) {
294+
$text = '/* detect loader */';
293295
}
294296
return $start_tag . $text . $end_tag;
295297
},

plugins/optimization-detective/tests/test-detection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public function test_od_get_detection_script_returns_script( Closure $set_up, ar
222222
$script = od_get_detection_script( $slug, $group_collection );
223223

224224
$this->assertStringContainsString( '<script type="module">', $script );
225-
$this->assertStringContainsString( 'import detect from', $script );
225+
$this->assertStringContainsString( 'async function load', $script );
226226
foreach ( $expected_exports as $key => $value ) {
227227
$this->assertStringContainsString( sprintf( '%s:%s', wp_json_encode( $key ), wp_json_encode( $value ) ), $script );
228228
}

0 commit comments

Comments
 (0)