From 92bd45c212cc0d3085d2b37003452470c2a37cd8 Mon Sep 17 00:00:00 2001 From: Hisham Date: Thu, 1 Aug 2024 23:25:34 +0530 Subject: [PATCH 1/2] Update channel tests - takeComplete() --- .../kotlin/app/cash/turbine/ChannelTest.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/commonTest/kotlin/app/cash/turbine/ChannelTest.kt b/src/commonTest/kotlin/app/cash/turbine/ChannelTest.kt index d4d03571..fed4da5b 100644 --- a/src/commonTest/kotlin/app/cash/turbine/ChannelTest.kt +++ b/src/commonTest/kotlin/app/cash/turbine/ChannelTest.kt @@ -261,6 +261,19 @@ class ChannelTest { assertEquals("Expected item but found Error(CustomThrowable)", actual.message) assertSame(error, actual.cause) } + + @Test fun takeComplete() = withTestScope { + val channel = channelOf("item!") + channel.takeItem() + channel.takeComplete() + } + + @Test fun takeCompleteFailsForItem() = withTestScope { + val channel = channelOf("item!") + assertFailsWith { + channel.takeComplete() + } + } @Test fun expectMostRecentItemButNoItemWasFoundThrowsWithName() = runTest { From 68c5a7dfa5c323fefd3660d62fb4b449496cf7de Mon Sep 17 00:00:00 2001 From: Hisham Date: Thu, 1 Aug 2024 23:51:15 +0530 Subject: [PATCH 2/2] fixed spotless --- src/commonTest/kotlin/app/cash/turbine/ChannelTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commonTest/kotlin/app/cash/turbine/ChannelTest.kt b/src/commonTest/kotlin/app/cash/turbine/ChannelTest.kt index fed4da5b..30e27cae 100644 --- a/src/commonTest/kotlin/app/cash/turbine/ChannelTest.kt +++ b/src/commonTest/kotlin/app/cash/turbine/ChannelTest.kt @@ -261,7 +261,7 @@ class ChannelTest { assertEquals("Expected item but found Error(CustomThrowable)", actual.message) assertSame(error, actual.cause) } - + @Test fun takeComplete() = withTestScope { val channel = channelOf("item!") channel.takeItem()