Skip to content

Commit 66a341d

Browse files
committed
Add test case for getTags should reflect any tags modification
1 parent 82c26b2 commit 66a341d

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

OneSignalSDK/onesignal/core/src/test/java/com/onesignal/user/internal/UserManagerTests.kt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import com.onesignal.user.internal.subscriptions.ISubscriptionManager
66
import com.onesignal.user.internal.subscriptions.SubscriptionList
77
import io.kotest.core.spec.style.FunSpec
88
import io.kotest.matchers.shouldBe
9+
import io.kotest.matchers.shouldNotBe
910
import io.kotest.runner.junit4.KotestTestRunner
1011
import io.mockk.every
1112
import io.mockk.just
@@ -147,11 +148,18 @@ class UserManagerTests : FunSpec({
147148
UserManager(mockSubscriptionManager, MockHelper.identityModelStore(), propertiesModelStore, MockHelper.languageContext())
148149

149150
// When
150-
val allTags = userManager.getTags()
151+
val tagSnapshot1 = userManager.getTags()
151152

152153
// Then
153-
allTags.size shouldBe propertiesModelStore.model.tags.size
154-
allTags["my-tag-key1"] shouldBe propertiesModelStore.model.tags["my-tag-key1"]
154+
tagSnapshot1.size shouldBe propertiesModelStore.model.tags.size
155+
tagSnapshot1["my-tag-key1"] shouldBe propertiesModelStore.model.tags["my-tag-key1"]
156+
157+
// Modify
158+
userManager.addTag("my-tag-key2", "my-tag-value2")
159+
userManager.getTags().size shouldBe 2
160+
161+
// Then
162+
tagSnapshot1.size shouldNotBe userManager.getTags().size
155163
}
156164

157165
test("subscriptions are backed by the subscriptions manager") {

0 commit comments

Comments
 (0)