Skip to content

Commit

Permalink
Fixing and adding acceptance test
Browse files Browse the repository at this point in the history
  • Loading branch information
dpanta94 committed Dec 17, 2024
1 parent fdcb23b commit 303583b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/acceptance/EnqueueCSSCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,31 @@ public function it_should_set_media( AcceptanceTester $I ) {
$I->dontSeeElement( 'link', [ 'href' => 'http://wordpress.test/wp-content/plugins/assets/tests/_data/css/fake.css?ver=1.0.0', 'media' => 'screen' ] );
}

public function it_should_enqueue_css_on_default_version_when_using_register_with_js( AcceptanceTester $I ) {
$code = file_get_contents( codecept_data_dir( 'enqueue-template.php' ) );
$code .= <<<PHP
add_action( 'wp_enqueue_scripts', function() {
Asset::add( 'something-css' . uniqid(), 'something.css' )
->set_path( 'tests/_data/build' )
->enqueue_on( 'wp_enqueue_scripts' )
->register_with_js();
}, 100 );
PHP;

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


$I->amOnPage( '/' );
$I->seeElement( 'link', [ 'href' => 'http://wordpress.test/wp-content/plugins/assets/tests/_data/build/something.css?ver=1.0.0' ] );
$I->seeElement( 'script', [ 'src' => 'http://wordpress.test/wp-content/plugins/assets/tests/_data/build/something.js?ver=1.0.0' ] );
}

public function it_should_enqueue_js_when_using_register_with_js( AcceptanceTester $I ) {
$code = file_get_contents( codecept_data_dir( 'enqueue-template.php' ) );
$code .= <<<PHP
add_action( 'wp_enqueue_scripts', function() {
Asset::add( 'something-css' . uniqid(), 'something.css' )
->use_asset_file( true )
->set_path( 'tests/_data/build' )
->enqueue_on( 'wp_enqueue_scripts' )
->register_with_js();
Expand Down

0 comments on commit 303583b

Please sign in to comment.