Skip to content

Commit

Permalink
Empty iterable leaves no whitespace (#267)
Browse files Browse the repository at this point in the history
* build: upgrade to stable dom release

* test: bind objects in arrays with bindList

* test: binding an empty list leaves no whitespace
closes #260
  • Loading branch information
g105b authored Oct 9, 2021
1 parent 895b87d commit 1b89af7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/phpunit/DocumentBinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,14 @@ public function testBindList():void {
}
}

public function testBindList_emptyLeavesNoWhiteSpace():void {
$document = DocumentTestFactory::createHTML(DocumentTestFactory::HTML_LIST_TEMPLATE);
$sut = new DocumentBinder($document);
$listData = [];
$sut->bindList($listData);
self::assertEquals("", $document->querySelector("ul")->innerHTML);
}

public function testBindData_objectWithAttribute():void {
$document = DocumentTestFactory::createHTML(DocumentTestFactory::HTML_USER_PROFILE);
$sut = new DocumentBinder($document);
Expand Down
8 changes: 8 additions & 0 deletions test/phpunit/ListBinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ public function testBindList_emptyList():void {
self::assertSame(0, $boundCount);
}

public function testBindList_empty_shouldHaveNoWhitespace():void {
$document = DocumentTestFactory::createHTML(DocumentTestFactory::HTML_LIST_TEMPLATE);
$templateCollection = new TemplateCollection($document);
$sut = new ListBinder($templateCollection);
$sut->bindListData([], $document);
self::assertSame("", $document->querySelector("ul")->innerHTML);
}

public function testBindList_emptyList_iterator():void {
$document = DocumentTestFactory::createHTML(DocumentTestFactory::HTML_LIST_TEMPLATE);

Expand Down

0 comments on commit 1b89af7

Please sign in to comment.