-
Notifications
You must be signed in to change notification settings - Fork 524
Expand file tree
/
Copy pathNotificationStorageActionsTest.kt
More file actions
48 lines (41 loc) · 1.4 KB
/
NotificationStorageActionsTest.kt
File metadata and controls
48 lines (41 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
package app.tauri.notification
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import com.fasterxml.jackson.databind.ObjectMapper
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class NotificationStorageActionsTest {
@Test
fun actionGroup_roundTrip() {
val context = InstrumentationRegistry.getInstrumentation().targetContext
val storage = NotificationStorage(context, ObjectMapper())
val reply = NotificationAction().apply {
id = "reply"
title = "Reply"
input = true
}
val markRead = NotificationAction().apply {
id = "mark-read"
title = "Mark Read"
input = false
}
val type = ActionType().apply {
id = "chat-actions"
actions = listOf(reply, markRead)
}
storage.writeActionGroup(listOf(type))
val restored = storage.getActionGroup("chat-actions")
assertEquals(2, restored.size)
assertEquals("reply", restored[0]!!.id)
assertEquals("Reply", restored[0]!!.title)
assertTrue(restored[0]!!.input == true)
assertEquals("mark-read", restored[1]!!.id)
assertEquals("Mark Read", restored[1]!!.title)
}
}