Skip to content

Commit 39d981d

Browse files
committed
add no-title-property test
1 parent ad5d85d commit 39d981d

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

tests/RecordedEndpointDatabasesCreationTest.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@
2727
->storeIn('snapshots/databases');
2828
});
2929

30+
it('should throw a handling exception if no title property is added', function(){
31+
$this->httpRecorder->nameForNextRequest('400-no-title-property');
32+
$this->expectException(\FiveamCode\LaravelNotionApi\Exceptions\NotionException::class);
33+
$this->expectExceptionMessage('Bad Request: (validation_error) (Title is not provided)');
34+
$this->expectExceptionCode(400);
35+
36+
\Notion::databases()
37+
->build()
38+
->add(PropertyBuilder::checkbox('Test Checkbox'))
39+
->createInPage('0adbc2eb57e84569a700a70d537615be');
40+
});
41+
3042
it('should create a new database with all available properties', function () {
3143
$this->httpRecorder->nameForNextRequest('all-properties');
3244

@@ -74,6 +86,13 @@
7486
->description('This Database has been created by a Pest Test from Laravel')
7587
->add($scheme)
7688
->createInPage('0adbc2eb57e84569a700a70d537615be');
89+
90+
expect($databaseEntity->getCover())->toEqual('https://example.com/cover.jpg');
91+
expect($databaseEntity->getIcon())->toEqual('https://example.com/cover.jpg');
92+
//TODO: Currently not supported due to Notion API versioning
93+
// expect($databaseEntity->getDescription())->toEqual('This Database has been created by a Pest Test from Laravel');
94+
expect($databaseEntity->getTitle())->toEqual('Created By Testing Database');
95+
expect($databaseEntity->getParentId())->toEqual('0adbc2eb-57e8-4569-a700-a70d537615be');
7796

7897
expect($databaseEntity->getProperties())->toHaveCount(18);
7998
expect($databaseEntity->getProperty('Test Title'))->toBeInstanceOf(Title::class);
@@ -104,4 +123,4 @@
104123
expect($databaseEntity->getProperty('Test MultiSelect')->getOptions()[0]->getColor())->toEqual($multiSelectOptions[0]['color']);
105124

106125
expect($databaseEntity->getProperty('Test Number')->getRawResponse()['number']['format'])->toBe('dollar');
107-
});
126+
});

0 commit comments

Comments
 (0)