Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sirreal committed Jan 23, 2024
1 parent 5077e49 commit ff53771
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/phpunit/data/blocks/notice/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"editorScript": "tests-notice-editor-script",
"script": "tests-notice-script",
"viewScript": [ "tests-notice-view-script", "tests-notice-view-script-2" ],
"viewScriptModule": [ "tests-notice-view-script-module", "tests-notice-view-script-module-2" ],
"editorStyle": "tests-notice-editor-style",
"style": [ "tests-notice-style", "tests-notice-style-2" ],
"render": "file:./render.php"
Expand Down
28 changes: 28 additions & 0 deletions tests/phpunit/tests/blocks/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,18 @@ public function test_generate_block_asset_handle() {
'unit-tests-my-block-view-script-100',
generate_block_asset_handle( $block_name, 'viewScript', 99 )
);
$this->assertSame(
'unit-tests-my-block-view-script-module',
generate_block_asset_handle( $block_name, 'viewScriptModule' )
);
$this->assertSame(
'unit-tests-my-block-view-script-module-2',
generate_block_asset_handle( $block_name, 'viewScriptModule', 1 )
);
$this->assertSame(
'unit-tests-my-block-view-script-module-100',
generate_block_asset_handle( $block_name, 'viewScriptModule', 99 )
);
$this->assertSame(
'unit-tests-my-block-editor-style-2',
generate_block_asset_handle( $block_name, 'editorStyle', 1 )
Expand Down Expand Up @@ -176,6 +188,18 @@ public function test_generate_block_asset_handle_core_block() {
'wp-block-paragraph-view-100',
generate_block_asset_handle( $block_name, 'viewScript', 99 )
);
$this->assertSame(
'unit-tests-my-block-view-script-module',
generate_block_asset_handle( $block_name, 'viewScriptModule' )
);
$this->assertSame(
'unit-tests-my-block-view-script-module-2',
generate_block_asset_handle( $block_name, 'viewScriptModule', 1 )
);
$this->assertSame(
'unit-tests-my-block-view-script-module-100',
generate_block_asset_handle( $block_name, 'viewScriptModule', 99 )
);
$this->assertSame(
'wp-block-paragraph-editor-2',
generate_block_asset_handle( $block_name, 'editorStyle', 1 )
Expand Down Expand Up @@ -829,6 +853,10 @@ public function test_block_registers_with_metadata_fixture() {
array( 'tests-notice-view-script', 'tests-notice-view-script-2' ),
$result->view_script_handles
);
$this->assertSameSets(
array( 'tests-notice-view-script-module', 'tests-notice-view-script-module-2' ),
$result->view_script_module_ids
);
$this->assertSameSets(
array( 'tests-notice-editor-style' ),
$result->editor_style_handles
Expand Down

0 comments on commit ff53771

Please sign in to comment.