You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: core/android/common/src/test/kotlin/app/k9mail/core/android/common/contact/CachingContactRepositoryTest.kt
+50Lines changed: 50 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,6 @@
1
1
packageapp.k9mail.core.android.common.contact
2
2
3
+
importandroid.net.Uri
3
4
importassertk.assertThat
4
5
importassertk.assertions.isEqualTo
5
6
importassertk.assertions.isFalse
@@ -140,4 +141,53 @@ internal class CachingContactRepositoryTest {
140
141
141
142
assertThat(cache[CONTACT_EMAIL_ADDRESS]).isNull()
142
143
}
144
+
145
+
@Test
146
+
fun`getPhotoUri() returns null when email is invalid`() {
147
+
val result = testSubject.getPhotoUri("invalid-email")
148
+
149
+
assertThat(result).isNull()
150
+
}
151
+
152
+
@Test
153
+
fun`getPhotoUri() returns null when no contact found for valid email`() {
154
+
dataSource.stub { on { getContactFor(CONTACT_EMAIL_ADDRESS) } doReturn null }
155
+
156
+
val result = testSubject.getPhotoUri(CONTACT_EMAIL_ADDRESS.address)
157
+
158
+
assertThat(result).isNull()
159
+
}
160
+
161
+
@Test
162
+
fun`getPhotoUri() returns contact photo uri when contact exists`() {
163
+
dataSource.stub { on { getContactFor(CONTACT_EMAIL_ADDRESS) } doReturn CONTACT }
164
+
165
+
val result = testSubject.getPhotoUri(CONTACT_EMAIL_ADDRESS.address)
166
+
167
+
assertThat(result).isEqualTo(CONTACT.photoUri)
168
+
}
169
+
170
+
@Test
171
+
fun`getPhotoUri() returns cached photo uri when contact already cached`() {
172
+
cache[CONTACT_EMAIL_ADDRESS] =CONTACT
173
+
174
+
val result = testSubject.getPhotoUri(CONTACT_EMAIL_ADDRESS.address)
175
+
176
+
assertThat(result).isEqualTo(CONTACT.photoUri)
177
+
}
178
+
179
+
@Test
180
+
fun`getPhotoUri() caches result after first fetch`() {
181
+
dataSource.stub {
182
+
on { getContactFor(CONTACT_EMAIL_ADDRESS) } doReturnConsecutively listOf(
0 commit comments