@@ -105,6 +105,8 @@ class PubkyRepoTest : BaseUnitTest() {
105105 val ffiProfile = mock<CorePubkyProfile >()
106106 whenever(ffiProfile.name).thenReturn(" User" )
107107 whenever(pubkyService.getProfile(VALID_SELF_KEY )).thenReturn(ffiProfile)
108+ whenever(keychain.loadString(Keychain .Key .PAYKIT_SESSION .name)).thenReturn(testSecret)
109+ whenever(pubkyService.sessionList(testSecret, Env .contactsBasePath)).thenReturn(emptyList())
108110
109111 val result = sut.completeAuthentication()
110112
@@ -122,6 +124,8 @@ class PubkyRepoTest : BaseUnitTest() {
122124 whenever(pubkyService.importSession(testSecret)).thenReturn(testPk)
123125 val ffiProfile = createFfiProfile(name = " User" )
124126 whenever(pubkyService.getProfile(VALID_SELF_KEY )).thenReturn(ffiProfile)
127+ whenever(keychain.loadString(Keychain .Key .PAYKIT_SESSION .name)).thenReturn(testSecret)
128+ whenever(pubkyService.sessionList(testSecret, Env .contactsBasePath)).thenReturn(emptyList())
125129
126130 val result = sut.completeAuthentication()
127131
@@ -130,18 +134,20 @@ class PubkyRepoTest : BaseUnitTest() {
130134 }
131135
132136 @Test
133- fun `completeAuthentication should not load contacts automatically` () = test {
137+ fun `completeAuthentication should load contacts automatically` () = test {
134138 val testSecret = " session_secret"
135139 val testPk = VALID_SELF_KEY .removePrefix(" pubky" )
136140 whenever(pubkyService.completeAuth()).thenReturn(testSecret)
137141 whenever(pubkyService.importSession(testSecret)).thenReturn(testPk)
138142 val ffiProfile = createFfiProfile(name = " User" )
139143 whenever(pubkyService.getProfile(VALID_SELF_KEY )).thenReturn(ffiProfile)
144+ whenever(keychain.loadString(Keychain .Key .PAYKIT_SESSION .name)).thenReturn(testSecret)
145+ whenever(pubkyService.sessionList(testSecret, Env .contactsBasePath)).thenReturn(emptyList())
140146
141147 val result = sut.completeAuthentication()
142148
143149 assertTrue(result.isSuccess)
144- verify(pubkyService, never()) .sessionList(any(), any() )
150+ verify(pubkyService) .sessionList(testSecret, Env .contactsBasePath )
145151 }
146152
147153 @Test
0 commit comments