-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update When Date class to use `WhenType` of `DATE` instead of `DATESPAN`. # License <!-- Your PR comment must contain the following line for us to merge the PR. --> I confirm that this contribution is made under the terms of the MIT license and that I have the authority necessary to make this contribution on behalf of its copyright owner. Co-authored-by: Nick Bair <[email protected]>
- Loading branch information
1 parent
8da481f
commit d173b93
Showing
2 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,6 +156,56 @@ class EventsTests { | |
assertEquals("America/New_York", whenTimespan.startTimezone) | ||
assertEquals("America/New_York", whenTimespan.endTimezone) | ||
} | ||
|
||
@Test | ||
fun `Event serializes when with date type properly`() { | ||
val adapter = JsonHelper.moshi().adapter(Event::class.java) | ||
val jsonBuffer = | ||
Buffer().writeUtf8( | ||
""" | ||
{ | ||
"busy": true, | ||
"calendar_id": "7d93zl2palhxqdy6e5qinsakt", | ||
"created_at": 1661874192, | ||
"description": "Description of my new calendar", | ||
"hide_participants": false, | ||
"grant_id": "41009df5-bf11-4c97-aa18-b285b5f2e386", | ||
"html_link": "https://www.google.com/calendar/event?eid=bTMzcGJrNW4yYjk4bjk3OWE4Ef3feD2VuM29fMjAyMjA2MjdUMjIwMDAwWiBoYWxsYUBueWxhcy5jb20", | ||
"id": "5d3qmne77v32r8l4phyuksl2x", | ||
"location": "Roller Rink", | ||
"object": "event", | ||
"organizer": { | ||
"email": "[email protected]", | ||
"name": "" | ||
}, | ||
"read_only": false, | ||
"reminders": { | ||
"use_default": false, | ||
"overrides": [ | ||
{ | ||
"reminder_minutes": 10, | ||
"reminder_method": "email" | ||
} | ||
] | ||
}, | ||
"status": "confirmed", | ||
"title": "Birthday Party", | ||
"updated_at": 1661874192, | ||
"visibility": "private", | ||
"when": { | ||
"date": "2024-06-18", | ||
"object": "date" | ||
} | ||
} | ||
""".trimIndent(), | ||
) | ||
|
||
val event = adapter.fromJson(jsonBuffer)!! | ||
assertIs<Event>(event) | ||
assertIs<When.Date>(event.getWhen()) | ||
val whenDate = event.getWhen() as When.Date | ||
assertEquals("2024-06-18", whenDate.date) | ||
} | ||
} | ||
|
||
@Nested | ||
|