Skip to content

Commit aa1d4a1

Browse files
committed
chore: updated test
Signed-off-by: Mac Deluca <Mac.Deluca@quartech.com>
1 parent dd6e156 commit aa1d4a1

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

app/__tests__/bcsc-theme/hooks/useQuickLoginURL.test.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
jest.mock('@bifold/core')
2-
jest.mock('@/bcsc-theme/api/hooks/useApi')
3-
jest.mock('@/bcsc-theme/hooks/useBCSCApiClient')
4-
jest.mock('@/bcsc-theme/hooks/useDataLoader', () => ({
5-
__esModule: true,
6-
default: jest.fn(),
7-
}))
8-
91
import * as useApi from '@/bcsc-theme/api/hooks/useApi'
102
import * as useBCSCApiClient from '@/bcsc-theme/hooks/useBCSCApiClient'
113
import useDataLoader from '@/bcsc-theme/hooks/useDataLoader'
124
import { useQuickLoginURL } from '@/bcsc-theme/hooks/useQuickLoginUrl'
135
import * as Bifold from '@bifold/core'
146
import { renderHook, waitFor } from '@testing-library/react-native'
157

8+
jest.mock('@bifold/core')
9+
jest.mock('@/bcsc-theme/api/hooks/useApi')
10+
jest.mock('@/bcsc-theme/hooks/useBCSCApiClient')
11+
jest.mock('@/bcsc-theme/hooks/useDataLoader')
12+
1613
describe('useQuickLoginURL', () => {
1714
beforeEach(() => {
1815
jest.resetAllMocks()
@@ -24,7 +21,7 @@ describe('useQuickLoginURL', () => {
2421
const bifoldMock = jest.mocked(Bifold)
2522
const useDataLoaderMock = jest.mocked(useDataLoader)
2623

27-
useApiMock.default.mockReturnValue({ jwks: jest.fn() } as any)
24+
useApiMock.default.mockReturnValue({ jwks: { getFirstJwk: jest.fn() } } as any)
2825
useClientMock.useBCSCApiClient.mockReturnValue({} as any)
2926
bifoldMock.useServices.mockReturnValue([{ error: jest.fn() }] as any)
3027

@@ -37,11 +34,12 @@ describe('useQuickLoginURL', () => {
3734
.mockReturnValueOnce(tokensLoaderMock)
3835
.mockReturnValueOnce(accountLoaderMock)
3936

40-
const hook = renderHook(() => useQuickLoginURL({ client_ref_id: '', initiate_login_uri: 'https://login' }))
37+
const hook = renderHook(() => useQuickLoginURL({ client_ref_id: '' }))
4138

4239
// Wait for useEffect to run
4340
await waitFor(() => {
4441
const [url, error] = hook.result.current
42+
4543
expect(url).toBeNull()
4644
expect(error).toBeNull()
4745
})

app/src/bcsc-theme/features/services/ServiceLoginScreen.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,9 @@ export const ServiceLoginScreen: React.FC<ServiceLoginScreenProps> = (props: Ser
161161
return
162162
}
163163

164-
// This should never happen, but just in case...
165-
Alert.alert(t('Services.LoginErrorTitle'), quickLoginError ?? undefined)
164+
if (quickLoginError) {
165+
Alert.alert(t('Services.LoginErrorTitle'), quickLoginError)
166+
}
166167
}}
167168
/>
168169
</View>

app/src/bcsc-theme/hooks/useQuickLoginUrl.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export const useQuickLoginURL = (serviceClient: ClientMetadataStub): QuickLoginU
101101
handleQuickLoginUpdate(`${serviceClient.initiate_login_uri}?login_hint=${encodedTokenHint}`, null)
102102
} catch (error) {
103103
logger.error('Error creating quick login URL', error as Error)
104-
handleQuickLoginUpdate(null, `Error creating quick login URL ${(error as Error).message}`)
104+
handleQuickLoginUpdate(null, `Error creating quick login URL: ${(error as Error).message}`)
105105
}
106106
}
107107

0 commit comments

Comments
 (0)