@@ -6,6 +6,7 @@ import org.junit.Assert.assertNull
66import org.junit.Test
77import video.typetype.tv.data.Channel
88import video.typetype.tv.data.ChannelTab
9+ import video.typetype.tv.data.Chapter
910import video.typetype.tv.data.SearchKind
1011import video.typetype.tv.data.TwitchCategory
1112import video.typetype.tv.data.TwitchChannelPage
@@ -72,6 +73,16 @@ class TwitchContentTest {
7273 private fun video (id : String , isLive : Boolean = false): Video =
7374 Video (id, id, channel, 0 , " " , " " , " " , " " , isLive = isLive)
7475
76+ @Test
77+ fun aPastBroadcastCarriesItsGameChaptersOnlyWhenThereAreSeveral () = runBlocking {
78+ chapterList = listOf (Chapter (" Fortnite" , 0 ), Chapter (" Just Chatting" , 559 ))
79+ assertEquals(listOf (0 , 559 ), content.video(TwitchTarget .Vod (" 1" ))?.chapters?.map { it.startSeconds })
80+ chapterList = listOf (Chapter (" Fortnite" , 0 ))
81+ assertEquals(emptyList<Chapter >(), content.video(TwitchTarget .Vod (" 1" ))?.chapters)
82+ }
83+
84+ private var chapterList: List <Chapter > = emptyList()
85+
7586 private inner class FakeTwitch : TwitchRepository {
7687 override val enabled: Boolean = true
7788 override suspend fun popular (cursor : String? ): TwitchPage <Video > = TwitchPage (listOf (live), null )
@@ -83,6 +94,7 @@ class TwitchContentTest {
8394 override suspend fun channelClips (login : String , cursor : String? ) = TwitchPage <Video >(emptyList(), null )
8495 override suspend fun live (login : String ): TwitchPlayback ? = if (online) TwitchPlayback (live, " https://i.example/live" , true ) else null
8596 override suspend fun vod (id : String ): TwitchPlayback = TwitchPlayback (vod, " https://i.example/vod" , false )
97+ override suspend fun chapters (id : String ) = chapterList
8698 override suspend fun clip (slug : String ): TwitchClipPlayback = TwitchClipPlayback (vod, emptyList())
8799 override suspend fun searchChannels (query : String , cursor : String? ) =
88100 TwitchPage (listOf (Channel (" space" , " Space" , " space" , " 1.9M" , TwitchUrls .live(" space" ))), " c2" )
0 commit comments