Skip to content

Commit

Permalink
Add acceptance test
Browse files Browse the repository at this point in the history
  • Loading branch information
dpanta94 committed Jun 14, 2024
1 parent 68ed60a commit b4fd2e7
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/acceptance/EnqueueJSCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,27 @@ public function it_should_enqueue_from_alternate_path_with_js_in_path( Acceptanc
$I->seeElement( 'script', [ 'src' => 'http://wordpress.test/wp-content/plugins/assets/tests/_data/other-asset-root/js/fake-alt.js?ver=1.0.0' ] );
}

public function it_should_enqueue_script_as_module( AcceptanceTester $I ) {
$code = file_get_contents( codecept_data_dir( 'enqueue-template.php' ) );
$code .= <<<PHP
add_action( 'wp_enqueue_scripts', function() {
Asset::add( 'fake-js', 'fake.js' )
->enqueue_on( 'wp_enqueue_scripts' )
->set_as_module( true )
->register();
Asset::add( 'fake3-js', 'fake3.js' )
->enqueue_on( 'wp_enqueue_scripts' )
->register();
}, 100 );
PHP;

$I->haveMuPlugin( 'enqueue.php', $code );

$I->amOnPage( '/' );
$I->seeElement( 'script', [ 'src' => 'http://wordpress.test/wp-content/plugins/assets/tests/_data/js/fake.js?ver=1.0.0', 'type' => 'module' ] );
$I->seeElement( 'script', [ 'src' => 'http://wordpress.test/wp-content/plugins/assets/tests/_data/js/fake3.min.js?ver=1.0.0' ] );
}

public function it_should_enqueue_min( AcceptanceTester $I ) {
$code = file_get_contents( codecept_data_dir( 'enqueue-template.php' ) );
$code .= <<<PHP
Expand Down

0 comments on commit b4fd2e7

Please sign in to comment.