|
| 1 | +/* |
| 2 | + * Copyright (c) 2014-2026 Stream.io Inc. All rights reserved. |
| 3 | + * |
| 4 | + * Licensed under the Stream License; |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://github.com/GetStream/stream-chat-android/blob/main/LICENSE |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package io.getstream.chat.android.compose.ui.components.composer |
| 18 | + |
| 19 | +import io.getstream.chat.android.models.AttachmentType |
| 20 | +import io.getstream.chat.android.randomAttachment |
| 21 | +import io.getstream.chat.android.randomString |
| 22 | +import org.junit.Assert.assertEquals |
| 23 | +import org.junit.Test |
| 24 | + |
| 25 | +internal class AnnounceAddedAttachmentTest { |
| 26 | + |
| 27 | + private val photoAttached = randomString() |
| 28 | + private val videoAttached = randomString() |
| 29 | + private val audioAttached = randomString() |
| 30 | + private val fileAttached = randomString() |
| 31 | + |
| 32 | + @Test |
| 33 | + fun `returns empty string when attachment is null`() { |
| 34 | + val result = announceAddedAttachment( |
| 35 | + added = null, |
| 36 | + photoAttached = photoAttached, |
| 37 | + videoAttached = videoAttached, |
| 38 | + audioAttached = audioAttached, |
| 39 | + fileAttached = fileAttached, |
| 40 | + ) |
| 41 | + |
| 42 | + assertEquals("", result) |
| 43 | + } |
| 44 | + |
| 45 | + @Test |
| 46 | + fun `returns photoAttached label for an image attachment`() { |
| 47 | + val result = announceAddedAttachment( |
| 48 | + added = randomAttachment(type = AttachmentType.IMAGE), |
| 49 | + photoAttached = photoAttached, |
| 50 | + videoAttached = videoAttached, |
| 51 | + audioAttached = audioAttached, |
| 52 | + fileAttached = fileAttached, |
| 53 | + ) |
| 54 | + |
| 55 | + assertEquals(photoAttached, result) |
| 56 | + } |
| 57 | + |
| 58 | + @Test |
| 59 | + fun `returns videoAttached label for a video attachment`() { |
| 60 | + val result = announceAddedAttachment( |
| 61 | + added = randomAttachment(type = AttachmentType.VIDEO), |
| 62 | + photoAttached = photoAttached, |
| 63 | + videoAttached = videoAttached, |
| 64 | + audioAttached = audioAttached, |
| 65 | + fileAttached = fileAttached, |
| 66 | + ) |
| 67 | + |
| 68 | + assertEquals(videoAttached, result) |
| 69 | + } |
| 70 | + |
| 71 | + @Test |
| 72 | + fun `returns audioAttached label for an audio recording attachment`() { |
| 73 | + val result = announceAddedAttachment( |
| 74 | + added = randomAttachment(type = AttachmentType.AUDIO_RECORDING), |
| 75 | + photoAttached = photoAttached, |
| 76 | + videoAttached = videoAttached, |
| 77 | + audioAttached = audioAttached, |
| 78 | + fileAttached = fileAttached, |
| 79 | + ) |
| 80 | + |
| 81 | + assertEquals(audioAttached, result) |
| 82 | + } |
| 83 | + |
| 84 | + @Test |
| 85 | + fun `returns fileAttached label for any other attachment type`() { |
| 86 | + val result = announceAddedAttachment( |
| 87 | + added = randomAttachment(type = AttachmentType.FILE), |
| 88 | + photoAttached = photoAttached, |
| 89 | + videoAttached = videoAttached, |
| 90 | + audioAttached = audioAttached, |
| 91 | + fileAttached = fileAttached, |
| 92 | + ) |
| 93 | + |
| 94 | + assertEquals(fileAttached, result) |
| 95 | + } |
| 96 | +} |
0 commit comments