From b4fd2e785caddab82f655bf901e2cb8c4c39cf59 Mon Sep 17 00:00:00 2001 From: Dimitrios Pantazis Date: Fri, 14 Jun 2024 19:52:15 +0300 Subject: [PATCH] Add acceptance test --- tests/acceptance/EnqueueJSCest.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/acceptance/EnqueueJSCest.php b/tests/acceptance/EnqueueJSCest.php index 1aac8a3..495039e 100644 --- a/tests/acceptance/EnqueueJSCest.php +++ b/tests/acceptance/EnqueueJSCest.php @@ -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 .= <<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 .= <<