Skip to content

Commit

Permalink
Test Markdown method returns collection of Markdown documents
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Jun 24, 2024
1 parent d9bb52a commit 1570c8b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/framework/tests/Unit/DataCollectionUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Collection;
use Mockery;
use Hyde\Markdown\Models\MarkdownDocument;

/**
* @covers \Hyde\Support\DataCollection
Expand Down Expand Up @@ -100,6 +101,23 @@ public function testStaticMarkdownHelperReturnsNewDataCollectionInstance()
{
$this->assertInstanceOf(DataCollection::class, DataCollection::markdown('foo'));
}

public function testMarkdownMethodReturnsCollectionOfMarkdownDocuments()
{
MockableDataCollection::mockFiles([
'foo/bar.md' => 'bar',
'foo/baz.md' => 'baz',
]);

$collection = MockableDataCollection::markdown('foo');

$this->assertContainsOnlyInstancesOf(MarkdownDocument::class, $collection);

$this->assertSame([
'bar' => 'bar',
'baz' => 'baz',
], $collection->map(fn ($value) => (string) $value)->all());
}
}

class MockableDataCollection extends DataCollection
Expand Down

0 comments on commit 1570c8b

Please sign in to comment.