Skip to content

Commit

Permalink
Fix code block creation without block ID (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
AdryanSignor authored Dec 5, 2024
1 parent 57024db commit d489778
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Blocks/Virtual/VirtualBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public function getIterator(): Traversable
{
$blocks = parent::getIterator();
if ($this->blockId === null) {
return $blocks;
yield from $blocks;
return;
}

$index = 1;
Expand Down
3 changes: 3 additions & 0 deletions tests/Functional/CreateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ public function testCreatedVirtualComponentsMatchExpectedOutputJson(): void
my code
CODE,
),
Kit::codeBlock(
code: 'Code block without blockId'
)
],
);

Expand Down
7 changes: 7 additions & 0 deletions tests/Functional/assets/create/virtual-blocks.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@
"type": "mrkdwn",
"text": "```\nThis is\nmy code\n```"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "```\nCode block without blockId\n```"
}
}
]
}

0 comments on commit d489778

Please sign in to comment.