Skip to content

Commit 7b7395b

Browse files
committed
add resolve/parent tests regarding NotionParent
- specifically regarding type checking
1 parent f3aa549 commit 7b7395b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/RecordedEndpointResolveTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,29 @@
4444
$page = Notion::pages()->find('a652fac351cc4cc79f5b17eb702793ed');
4545
$parentPage = Notion::resolve()->parent($page->getParent());
4646

47+
expect($page->getParent()->isPage())->toBeTrue();
48+
4749
expect($parentPage)->toBeInstanceOf(\FiveamCode\LaravelNotionApi\Entities\Page::class);
4850
expect($parentPage->getId())->toBe('5ac149b9-d8f1-4d8d-ac05-facefc16ebf7');
4951
expect($parentPage->getTitle())->toBe('Resolve Endpoint - Testing Suite');
5052
});
5153

54+
it('should return the workspace parent of a page without resolving it', function () {
55+
$page = Notion::pages()->find('91f70932ee6347b59bc243e09b4cc9b0');
56+
$parentWorkspace = Notion::resolve()->parent($page->getParent());
57+
58+
expect($page->getParent()->isWorkspace())->toBeTrue();
59+
60+
expect($parentWorkspace)->toBeInstanceOf(NotionParent::class);
61+
expect($parentWorkspace->getId())->toBe('1');
62+
expect($parentWorkspace->getObjectType())->toBe('workspace');
63+
});
64+
5265
it('should resolve the database parent of a page', function () {
5366
$page = Notion::pages()->find('415d9b6c6e454f42aab2b6e13804cfe9');
5467

68+
expect($page->getParent()->isDatabase())->toBeTrue();
69+
5570
$database = Notion::resolve()->parent($page->getParent());
5671
expect($database)->toBeInstanceOf(\FiveamCode\LaravelNotionApi\Entities\Database::class);
5772
expect($database->getId())->toBe('8a0ef209-8c8a-4fd1-a21c-db7ab327e870');
@@ -61,6 +76,8 @@
6176
it('should resolve the block parent of a block', function () {
6277
$block = Notion::block('d5f9419b44204c909501b1e2b7569503')->retrieve();
6378

79+
expect($block->getParent()->isBlock())->toBeTrue();
80+
6481
$parentBlock = Notion::resolve()->parent($block->getParent());
6582
expect($parentBlock)->toBeInstanceOf(\FiveamCode\LaravelNotionApi\Entities\Blocks\Block::class);
6683
expect($parentBlock->getId())->toBe('0971ac1a-b6f2-4acc-b706-f5f2ed16ffd6');

0 commit comments

Comments
 (0)