Skip to content

Commit a389879

Browse files
committed
add missing properties for database creation test
1 parent 54f10a3 commit a389879

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

tests/RecordedEndpointDatabasesCreationTest.php

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use FiveamCode\LaravelNotionApi\Entities\Properties\Number;
1515
use FiveamCode\LaravelNotionApi\Entities\Properties\People;
1616
use FiveamCode\LaravelNotionApi\Entities\Properties\PhoneNumber;
17+
use FiveamCode\LaravelNotionApi\Entities\Properties\Relation;
18+
use FiveamCode\LaravelNotionApi\Entities\Properties\Rollup;
1719
use FiveamCode\LaravelNotionApi\Entities\Properties\Select;
1820
use FiveamCode\LaravelNotionApi\Entities\Properties\Text;
1921
use FiveamCode\LaravelNotionApi\Entities\Properties\Title;
@@ -33,7 +35,7 @@
3335
$this->expectExceptionMessage('Bad Request: (validation_error) (Title is not provided)');
3436
$this->expectExceptionCode(400);
3537

36-
\Notion::databases()
38+
Notion::databases()
3739
->build()
3840
->add(PropertyBuilder::checkbox('Test Checkbox'))
3941
->createInPage('0adbc2eb57e84569a700a70d537615be');
@@ -72,12 +74,14 @@
7274
->phoneNumber('Test PhoneNumber')
7375
->people('Test People')
7476
->files('Test Files')
77+
->relation('Test Relation', '375da18ab01d42d18e95a9dc6a901db1')
78+
->rollup('Test Rollup', 'Tag', 'Test Relation', 'unique')
7579
->createdBy('Test Created By')
7680
->createdTime('Test Created Time')
7781
->lastEditedBy('Test Last Edited By')
7882
->lastEditedTime('Test Last Edited Time');
7983

80-
$databaseEntity = \Notion::databases()
84+
$databaseEntity = Notion::databases()
8185
->build()
8286
// ->inline() //TODO: Currently not supported due to Notion API versioning
8387
->title('Created By Testing Database')
@@ -94,7 +98,7 @@
9498
expect($databaseEntity->getTitle())->toEqual('Created By Testing Database');
9599
expect($databaseEntity->getParentId())->toEqual('0adbc2eb-57e8-4569-a700-a70d537615be');
96100

97-
expect($databaseEntity->getProperties())->toHaveCount(18);
101+
expect($databaseEntity->getProperties())->toHaveCount(20);
98102
expect($databaseEntity->getProperty('Test Title'))->toBeInstanceOf(Title::class);
99103
expect($databaseEntity->getProperty('Test Custom RichText'))->toBeInstanceOf(Text::class);
100104
expect($databaseEntity->getProperty('Test RichText'))->toBeInstanceOf(Text::class);
@@ -109,11 +113,19 @@
109113
expect($databaseEntity->getProperty('Test PhoneNumber'))->toBeInstanceOf(PhoneNumber::class);
110114
expect($databaseEntity->getProperty('Test People'))->toBeInstanceOf(People::class);
111115
expect($databaseEntity->getProperty('Test Files'))->toBeInstanceOf(Files::class);
116+
expect($databaseEntity->getProperty('Test Relation'))->toBeInstanceOf(Relation::class);
117+
expect($databaseEntity->getProperty('Test Rollup'))->toBeInstanceOf(Rollup::class);
112118
expect($databaseEntity->getProperty('Test Created By'))->toBeInstanceOf(CreatedBy::class);
113119
expect($databaseEntity->getProperty('Test Created Time'))->toBeInstanceOf(CreatedTime::class);
114120
expect($databaseEntity->getProperty('Test Last Edited By'))->toBeInstanceOf(LastEditedBy::class);
115121
expect($databaseEntity->getProperty('Test Last Edited Time'))->toBeInstanceOf(LastEditedTime::class);
116122

123+
expect($databaseEntity->getProperty('Test Relation')->getRelation()[0])->toBe('375da18a-b01d-42d1-8e95-a9dc6a901db1');
124+
125+
expect($databaseEntity->getProperty('Test Rollup')->getContent()["rollup_property_name"])->toBe("Tag");
126+
expect($databaseEntity->getProperty('Test Rollup')->getContent()["relation_property_name"])->toBe("Test Relation");
127+
expect($databaseEntity->getProperty('Test Rollup')->getContent()["function"])->toBe("unique");
128+
117129
expect($databaseEntity->getProperty('Test Select')->getOptions())->toHaveCount(count($selectOptions));
118130
expect($databaseEntity->getProperty('Test Select')->getOptions()[0]->getName())->toEqual($selectOptions[0]['name']);
119131
expect($databaseEntity->getProperty('Test Select')->getOptions()[0]->getColor())->toEqual($selectOptions[0]['color']);
@@ -124,3 +136,28 @@
124136

125137
expect($databaseEntity->getProperty('Test Number')->getRawResponse()['number']['format'])->toBe('dollar');
126138
});
139+
140+
it('should create a new database with default title property', function () {
141+
$this->httpRecorder->nameForNextRequest('with-emoji-icon');
142+
143+
$databaseEntity = Notion::databases()
144+
->build()
145+
->createInPage('0adbc2eb57e84569a700a70d537615be');
146+
147+
expect($databaseEntity->getProperties())->toHaveCount(1);
148+
expect($databaseEntity->getProperty('Name'))->toBeInstanceOf(Title::class);
149+
});
150+
151+
152+
it('should create a new database with emoji icon', function () {
153+
$this->httpRecorder->nameForNextRequest('only-title-properties');
154+
155+
$databaseEntity = Notion::databases()
156+
->build()
157+
->iconEmoji('👍')
158+
->createInPage('0adbc2eb57e84569a700a70d537615be');
159+
160+
expect($databaseEntity->getProperties())->toHaveCount(1);
161+
expect($databaseEntity->getProperty('Name'))->toBeInstanceOf(Title::class);
162+
expect($databaseEntity->getIcon())->toBe('👍');
163+
});

0 commit comments

Comments
 (0)