]+role="listitem"/ );
+
+ // The nested block delimiter belongs to the sub-list. The trailing space
+ // keeps item delimiters out of the count.
+ expect( content.split( '',
+ '
',
+ '
',
+ '',
+ '',
+ '

Image item
',
+ '
',
+ ''
+ ].join( '\n' );
+
+ await page.evaluate( content => window.wp.data.dispatch( 'core/editor' ).editPost( { content } ), markup );
+
+ const blocks = await editor.getBlocks();
+ expect( blocks.map( ( b ) => b.name ) ).toContain( 'themeisle-blocks/icon-list' );
+
+ await expect( editor.canvas.locator( '.block-editor-warning' ) ).toHaveCount( 0);
+ await expect( editor.canvas.getByText( 'Flat item' ) ).toBeVisible();
+ await expect( editor.canvas.getByText( 'Image item' ) ).toBeVisible();
+ });
});
diff --git a/src/blocks/test/unit/icon-list-sublist.test.js b/src/blocks/test/unit/icon-list-sublist.test.js
new file mode 100644
index 000000000..77db7e136
--- /dev/null
+++ b/src/blocks/test/unit/icon-list-sublist.test.js
@@ -0,0 +1,50 @@
+/**
+ * Internal dependencies
+ */
+import { getSubListAttributes } from '../../blocks/icon-list/sublist';
+
+describe( 'Icon List sub-list seeding', () => {
+ test( 'copies the parent list defaults onto the new sub-list', () => {
+ const parentAttributes = {
+ id: 'abc',
+ defaultLibrary: 'themeisle-icons',
+ defaultPrefix: 'fas',
+ defaultIcon: 'star',
+ defaultIconId: 12,
+ defaultIconAlt: 'A star',
+ defaultContentColor: '#111',
+ defaultIconColor: '#222',
+ defaultSize: '20px',
+ defaultIconSize: '16px',
+ sublistIndent: '40px',
+ gap: 5
+ };
+
+ expect( getSubListAttributes( parentAttributes ) ).toEqual( {
+ defaultLibrary: 'themeisle-icons',
+ defaultPrefix: 'fas',
+ defaultIcon: 'star',
+ defaultIconId: 12,
+ defaultIconAlt: 'A star',
+ defaultContentColor: '#111',
+ defaultIconColor: '#222',
+ defaultSize: '20px',
+ defaultIconSize: '16px'
+ } );
+
+ // The indent is not copied: a frozen copy would detach the sub-list
+ // from the parent's control. It reaches nested lists by inheritance.
+ expect( getSubListAttributes( parentAttributes ) ).not.toHaveProperty( 'sublistIndent' );
+ } );
+
+ test( 'omits unset attributes so the block defaults apply', () => {
+ expect( getSubListAttributes( { defaultIcon: 'check' } ) ).toEqual( {
+ defaultIcon: 'check'
+ } );
+ } );
+
+ test( 'returns an empty object when the parent has nothing to inherit', () => {
+ expect( getSubListAttributes( {} ) ).toEqual( {} );
+ expect( getSubListAttributes( undefined ) ).toEqual( {} );
+ } );
+} );
diff --git a/tests/test-icon-list-css.php b/tests/test-icon-list-css.php
new file mode 100644
index 000000000..66b285059
--- /dev/null
+++ b/tests/test-icon-list-css.php
@@ -0,0 +1,74 @@
+ $attrs Block attributes.
+ * @return string
+ */
+ private function render( array $attrs ): string {
+ $block = array(
+ 'blockName' => 'themeisle-blocks/icon-list',
+ 'attrs' => array_merge( array( 'id' => 'unittest123' ), $attrs ),
+ 'innerHTML' => '',
+ 'innerContent' => array(),
+ 'innerBlocks' => array(),
+ );
+
+ return (string) ( new Icon_List_CSS() )->render_css( $block );
+ }
+
+ /**
+ * A numeric indent is emitted with the pixel unit.
+ */
+ public function test_numeric_sublist_indent_is_emitted_in_px() {
+ $css = $this->render( array( 'sublistIndent' => 40 ) );
+
+ $this->assertStringContainsString( '--sublist-indent: 40px', $css );
+ }
+
+ /**
+ * A string indent keeps its own unit.
+ */
+ public function test_string_sublist_indent_is_emitted_as_is() {
+ $css = $this->render( array( 'sublistIndent' => '2rem' ) );
+
+ $this->assertStringContainsString( '--sublist-indent: 2rem', $css );
+ }
+
+ /**
+ * A unitless numeric string is emitted once, in pixels. Both the numeric
+ * and the string mappings would otherwise fire and the unitless value,
+ * coming last, would win in the cascade.
+ */
+ public function test_numeric_string_sublist_indent_is_emitted_once_in_px() {
+ $css = $this->render( array( 'sublistIndent' => '32' ) );
+
+ $this->assertSame( 1, substr_count( $css, '--sublist-indent' ) );
+ $this->assertStringContainsString( '--sublist-indent: 32px', $css );
+ }
+
+ /**
+ * No indent variable when the attribute is not set.
+ */
+ public function test_sublist_indent_is_skipped_without_value() {
+ $css = $this->render( array() );
+
+ $this->assertStringNotContainsString( '--sublist-indent', $css );
+ }
+}