@@ -156,6 +156,12 @@ public function test_generate_block_asset_handle() {
156156 'unit-tests-my-block-style ' ,
157157 generate_block_asset_handle ( $ block_name , 'style ' )
158158 );
159+ // @ticket 59673
160+ $ this ->assertSame (
161+ 'unit-tests-my-block-view-style ' ,
162+ generate_block_asset_handle ( $ block_name , 'viewStyle ' ),
163+ 'asset handle for viewStyle is not generated correctly '
164+ );
159165 }
160166
161167 /**
@@ -439,9 +445,10 @@ public function test_handles_passed_register_block_style_handles() {
439445 */
440446 public function test_success_register_block_style_handle () {
441447 $ metadata = array (
442- 'file ' => DIR_TESTDATA . '/blocks/notice/block.json ' ,
443- 'name ' => 'unit-tests/test-block ' ,
444- 'style ' => 'file:./block.css ' ,
448+ 'file ' => DIR_TESTDATA . '/blocks/notice/block.json ' ,
449+ 'name ' => 'unit-tests/test-block ' ,
450+ 'style ' => 'file:./block.css ' ,
451+ 'viewStyle ' => 'file:./block-view.css ' ,
445452 );
446453 $ result = register_block_style_handle ( $ metadata , 'style ' );
447454
@@ -454,6 +461,17 @@ public function test_success_register_block_style_handle() {
454461 wp_normalize_path ( wp_styles ()->get_data ( 'unit-tests-test-block-style ' , 'path ' ) )
455462 );
456463
464+ // Test viewStyle property
465+ $ result = register_block_style_handle ( $ metadata , 'viewStyle ' );
466+ $ this ->assertSame ( 'unit-tests-test-block-view-style ' , $ result );
467+
468+ // @ticket 59673
469+ $ this ->assertSame (
470+ wp_normalize_path ( realpath ( DIR_TESTDATA . '/blocks/notice/block-view.css ' ) ),
471+ wp_normalize_path ( wp_styles ()->get_data ( 'unit-tests-test-block-view-style ' , 'path ' ) ),
472+ 'viewStyle asset path is not correct '
473+ );
474+
457475 // Test the behavior directly within the unit test
458476 $ this ->assertFalse (
459477 strpos (
@@ -837,13 +855,26 @@ public function test_block_registers_with_metadata_fixture() {
837855 array ( 'tests-notice-style ' , 'tests-notice-style-2 ' ),
838856 $ result ->style_handles
839857 );
858+ // @ticket 59673
859+ $ this ->assertSameSets (
860+ array ( 'tests-notice-view-style ' ),
861+ $ result ->view_style_handles ,
862+ 'parsed view_style_handles is not correct '
863+ );
840864
841865 // @ticket 50328
842866 $ this ->assertSame (
843867 wp_normalize_path ( realpath ( DIR_TESTDATA . '/blocks/notice/block.css ' ) ),
844868 wp_normalize_path ( wp_styles ()->get_data ( 'unit-tests-test-block-style ' , 'path ' ) )
845869 );
846870
871+ // @ticket 59673
872+ $ this ->assertSame (
873+ wp_normalize_path ( realpath ( DIR_TESTDATA . '/blocks/notice/block-view.css ' ) ),
874+ wp_normalize_path ( wp_styles ()->get_data ( 'unit-tests-test-block-view-style ' , 'path ' ) ),
875+ 'viewStyle asset path is not correct '
876+ );
877+
847878 // @ticket 53148
848879 $ this ->assertIsCallable ( $ result ->render_callback );
849880 }
0 commit comments