Skip to content

Commit 995961f

Browse files
authored
Enhance tests for useRecordActionItems and AuthenticatorView; add OTP duplicate finder mock (#527)
1 parent d928e33 commit 995961f

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/hooks/useRecordActionItems.test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,15 @@ describe('useRecordActionItems', () => {
250250
test('handles edit action — uses OTP type when recordType is otp', () => {
251251
const otpLoginRecord = { id: '123', type: 'login', isFavorite: false }
252252

253+
useRouter.mockReturnValue({
254+
data: { recordType: 'otp' },
255+
navigate: mockNavigate,
256+
currentPage: 'somePage'
257+
})
258+
253259
const { result } = renderHook(() =>
254260
useRecordActionItems({
255261
record: otpLoginRecord,
256-
recordType: 'otp',
257262
onSelect: mockOnSelect,
258263
onClose: mockOnClose
259264
})

src/pages/AuthenticatorView/index.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ import { fireEvent, render, screen } from '@testing-library/react'
66
let mockSearchValue = ''
77
let mockRecords = []
88

9+
jest.mock('@tetherto/pearpass-lib-constants', () => ({
10+
DESKTOP_DESIGN_VERSION: 2,
11+
DESKTOP_2FA_IMPORTS_ENABLED: true
12+
}))
13+
914
jest.mock('@tetherto/pearpass-lib-vault', () => ({
1015
useRecords: () => ({
1116
data: mockRecords,

src/services/nativeMessagingIPCServer.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ jest.mock('./handlers/VaultHandlers', () => ({
161161
this.generateHotpNext = jest.fn().mockResolvedValue({ code: '123456' })
162162
this.addOtpToRecord = jest.fn().mockResolvedValue({ success: true })
163163
this.removeOtpFromRecord = jest.fn().mockResolvedValue({ success: true })
164+
this.findOtpDuplicates = jest.fn().mockResolvedValue({ duplicates: [] })
164165
})
165166
}))
166167

0 commit comments

Comments
 (0)