From 83d9c62391bfd1559898ba709980a03fbd9b32d5 Mon Sep 17 00:00:00 2001 From: Filipe de Lima Brito Date: Wed, 1 May 2019 12:05:29 -0300 Subject: [PATCH] Add test without names property --- .../rocket/core/internal/ReactionsAdapterTest.kt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/core/src/test/kotlin/chat/rocket/core/internal/ReactionsAdapterTest.kt b/core/src/test/kotlin/chat/rocket/core/internal/ReactionsAdapterTest.kt index 686fe3a1..f8515c49 100644 --- a/core/src/test/kotlin/chat/rocket/core/internal/ReactionsAdapterTest.kt +++ b/core/src/test/kotlin/chat/rocket/core/internal/ReactionsAdapterTest.kt @@ -14,7 +14,7 @@ import org.mockito.MockitoAnnotations import org.hamcrest.CoreMatchers.`is` as isEqualTo const val REACTIONS_JSON_PAYLOAD = "{\"reactions\":{\":croissant:\":{\"usernames\":[\"test.user\",\"test.user2\"],\"names\":[\"Test User\",\"Test User 2\"]}, \":thumbsup:\":{\"usernames\":[\"test.user\",\"test.user2\"],\"names\":[\"Test User\",\"Test User 2\"]}}}" -//const val REACTIONS_JSON_PAYLOAD = "{\"reactions\":{\":croissant:\":{\"usernames\":[\"test.user\",\"test.user2\"],\"names\":[\"Test User\",\"Test User 2\"]}}}" +const val REACTIONS_JSON_PAYLOAD_WITHOUT_NAME = "{\"reactions\":{\":croissant:\":{\"usernames\":[\"test.user\",\"test.user2\"]}, \":thumbsup:\":{\"usernames\":[\"test.user\",\"test.user2\"]}}}" const val REACTIONS_EMPTY_JSON_PAYLOAD = "[]" @@ -42,7 +42,7 @@ class ReactionsAdapterTest { } @Test - fun `should deserialize JSON with reactions`() { + fun `should deserialize JSON with reactions (with names)`() { val adapter = moshi.adapter(Reactions::class.java) adapter.fromJson(REACTIONS_JSON_PAYLOAD)?.let { reactions -> assertThat(reactions.size, isEqualTo(2)) @@ -53,6 +53,17 @@ class ReactionsAdapterTest { } } + @Test + fun `should deserialize JSON with reactions (without names)`() { + val adapter = moshi.adapter(Reactions::class.java) + adapter.fromJson(REACTIONS_JSON_PAYLOAD_WITHOUT_NAME)?.let { reactions -> + assertThat(reactions.size, isEqualTo(2)) + assertThat(reactions[":croissant:"]?.first?.size, isEqualTo(2)) + assertThat(reactions[":croissant:"]?.second?.size, isEqualTo(0)) + assertThat(reactions[":croissant:"]?.first?.get(0), isEqualTo("test.user")) + } + } + @Test fun `should deserialize empty reactions JSON`() { val adapter = moshi.adapter(Reactions::class.java)