Skip to content

Commit 0a07217

Browse files
committed
modify tests: evaluate 'hasTime' in date props
- add date with and without time in page response stub - assert true and false, if time is included - add these two additional properties within assert count of page results
1 parent c541080 commit 0a07217

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

tests/EndpointPagesTest.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,13 @@ public function it_returns_page_entity_with_filled_properties()
6969
// check properties
7070
$this->assertSame('Notion Is Awesome', $pageResult->getTitle());
7171
$this->assertSame('page', $pageResult->getObjectType());
72-
$this->assertCount(7, $pageResult->getRawProperties());
73-
$this->assertCount(7, $pageResult->getProperties());
74-
$this->assertCount(7, $pageResult->getPropertyKeys());
72+
$this->assertCount(9, $pageResult->getRawProperties());
73+
$this->assertCount(9, $pageResult->getProperties());
74+
$this->assertCount(9, $pageResult->getPropertyKeys());
75+
76+
// check date and datetime properties
77+
$this->assertTrue($pageResult->getProperty('DateWithTime')->hasTime());
78+
$this->assertFalse($pageResult->getProperty('DateWithoutTime')->hasTime());
7579

7680
$this->assertInstanceOf(Carbon::class, $pageResult->getCreatedTime());
7781
$this->assertInstanceOf(Carbon::class, $pageResult->getLastEditedTime());
@@ -179,6 +183,7 @@ public function it_assembles_properties_for_a_new_page()
179183
$this->assertTrue($dateRangeProp->isRange());
180184
$this->assertEquals($dateRangeStartValue, $dateRangeProp->getStart());
181185
$this->assertEquals($dateRangeEndValue, $dateRangeProp->getEnd());
186+
$this->assertFalse($dateRangeProp->hasTime());
182187
$this->assertJson($dateRangeProp->asText());
183188
$this->assertStringContainsString($dateRangeStartValue->format('Y-m-d H:i:s'), $dateRangeProp->asText());
184189
$this->assertStringContainsString($dateRangeEndValue->format('Y-m-d H:i:s'), $dateRangeProp->asText());
@@ -200,6 +205,7 @@ public function it_assembles_properties_for_a_new_page()
200205
$this->assertTrue($dateTimeRangeProp->isRange());
201206
$this->assertEquals($dateRangeStartValue, $dateTimeRangeProp->getStart());
202207
$this->assertEquals($dateRangeEndValue, $dateTimeRangeProp->getEnd());
208+
$this->assertTrue($dateTimeRangeProp->hasTime());
203209
$this->assertJson($dateTimeRangeProp->asText());
204210
$this->assertStringContainsString($dateRangeStartValue->format('Y-m-d H:i:s'), $dateTimeRangeProp->asText());
205211
$this->assertStringContainsString($dateRangeEndValue->format('Y-m-d H:i:s'), $dateTimeRangeProp->asText());
@@ -216,6 +222,8 @@ public function it_assembles_properties_for_a_new_page()
216222
$this->assertInstanceOf(RichDate::class, $dateProp->getContent());
217223
$this->assertFalse($dateProp->isRange());
218224
$this->assertEquals($dateValue, $dateProp->getStart());
225+
$this->assertNull($dateProp->getEnd());
226+
$this->assertFalse($dateProp->hasTime());
219227
$dateContent = $dateProp->getRawContent();
220228
$this->assertArrayHasKey('date', $dateContent);
221229
$this->assertCount(1, $dateContent['date']);
@@ -227,6 +235,8 @@ public function it_assembles_properties_for_a_new_page()
227235
$this->assertInstanceOf(RichDate::class, $dateTimeProp->getContent());
228236
$this->assertFalse($dateTimeProp->isRange());
229237
$this->assertEquals($dateValue, $dateTimeProp->getStart());
238+
$this->assertNull($dateTimeProp->getEnd());
239+
$this->assertTrue($dateTimeProp->hasTime());
230240
$dateTimeContent = $dateTimeProp->getRawContent();
231241
$this->assertArrayHasKey('date', $dateTimeContent);
232242
$this->assertCount(1, $dateTimeContent['date']);

tests/stubs/endpoints/pages/response_specific_200.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,24 @@
4040
}
4141
]
4242
},
43+
"DateWithTime":{
44+
"id": ">d{D",
45+
"type": "date",
46+
"date": {
47+
"start": "2021-05-14T00:00:00.000+00:00",
48+
"end": "2021-06-14T00:00:00.000+00:00",
49+
"time_zone": null
50+
}
51+
},
52+
"DateWithoutTime":{
53+
"id": ">c{d",
54+
"type": "date",
55+
"date": {
56+
"start": "2021-05-14",
57+
"end": "2021-06-14",
58+
"time_zone": null
59+
}
60+
},
4361
"SelectColumn": {
4462
"id": "nKff",
4563
"type": "select",

0 commit comments

Comments
 (0)