Skip to content

Commit 928820c

Browse files
committed
Update snapshots and tests
1 parent 2a819b4 commit 928820c

6 files changed

Lines changed: 199 additions & 13 deletions

File tree

package-lock.json

Lines changed: 136 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,19 @@
116116
"@types/react": "^19.2.4",
117117
"babel-jest": "29.7.0",
118118
"babel-plugin-macros": "3.1.0",
119+
"eslint": "9.39.2",
119120
"eslint-config-expo": "8.0.1",
120-
"tether-dev-docs": "file:packages/tether-dev-docs",
121+
"eslint-config-prettier": "10.1.8",
122+
"eslint-plugin-eslint-plugin": "6.5.0",
123+
"eslint-plugin-import": "2.32.0",
124+
"eslint-plugin-prettier": "5.5.4",
125+
"eslint-plugin-react": "7.37.5",
121126
"husky": "^9.1.7",
122127
"jest": "29.7.0",
123128
"jest-environment-jsdom": "^30.2.0",
129+
"prettier": "3.7.4",
124130
"react-test-renderer": "19.0.0",
131+
"tether-dev-docs": "file:packages/tether-dev-docs",
125132
"typescript": "~5.8.3"
126133
},
127134
"private": true

src/components/CustomFields/__snapshots__/index.test.jsx.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ exports[`CustomFields component renders correctly with note custom fields 1`] =
6262
"width": "100%",
6363
}
6464
}
65+
testID="note-0"
6566
>
6667
<View
6768
style={
@@ -197,6 +198,7 @@ exports[`CustomFields component renders correctly with note custom fields 1`] =
197198
},
198199
]
199200
}
201+
testID="note-0-input"
200202
value="test-note-value"
201203
/>
202204
</View>
@@ -381,6 +383,7 @@ exports[`CustomFields component renders correctly with note custom fields 1`] =
381383
"width": "100%",
382384
}
383385
}
386+
testID="note-1"
384387
>
385388
<View
386389
style={
@@ -516,6 +519,7 @@ exports[`CustomFields component renders correctly with note custom fields 1`] =
516519
},
517520
]
518521
}
522+
testID="note-1-input"
519523
value="test-note-value"
520524
/>
521525
</View>

src/components/Folder/__snapshots__/index.test.jsx.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ exports[`Folder component renders create new folder option without count 1`] = `
145145
"paddingBottom": 16,
146146
}
147147
}
148+
testID="sidebar-create-new"
148149
>
149150
<View
150151
style={

src/components/ListItem/index.test.jsx

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jest.mock('./styles', () => {
1111

1212
return {
1313
ListItemContainer: (props) => (
14-
<TouchableOpacity testID="vault-container" {...props}>
14+
<TouchableOpacity {...props} testID="vault-container">
1515
{props.children}
1616
</TouchableOpacity>
1717
),
@@ -29,17 +29,29 @@ jest.mock('./styles', () => {
2929
{props.children}
3030
</Text>
3131
),
32-
ListItemActions: (props) => <View testID="vault-actions" {...props} />
32+
ListItemActions: (props) => <View testID="vault-actions" {...props} />,
33+
SelectedListItemIconContainer: (props) => (
34+
<View testID="selected-icon-container" {...props} />
35+
)
3336
}
3437
})
3538

3639
jest.mock('pearpass-lib-ui-react-native-components', () => ({
3740
BrushIcon: () => 'BrushIcon',
41+
CheckIcon: () => 'CheckIcon',
3842
DeleteIcon: () => 'DeleteIcon',
3943
LockCircleIcon: () => 'LockCircleIcon',
4044
ShareIcon: () => 'ShareIcon'
4145
}))
4246

47+
jest.mock('pearpass-lib-ui-theme-provider/native', () => ({
48+
colors: {
49+
primary400: { mode1: '#000000' },
50+
black: { mode1: '#000000' },
51+
white: { mode1: '#ffffff' }
52+
}
53+
}))
54+
4355
describe('ListItem', () => {
4456
const mockProps = {
4557
name: 'Test Vault',
@@ -65,15 +77,13 @@ describe('ListItem', () => {
6577
expect(mockProps.onPress).toHaveBeenCalled()
6678
})
6779

68-
it('renders actions when showActions is true', () => {
69-
const { getByTestId } = render(
70-
<ListItem {...mockProps} showActions={true} />
71-
)
80+
it('renders actions when action callbacks are provided', () => {
81+
const { getByTestId } = render(<ListItem {...mockProps} />)
7282

7383
expect(getByTestId('vault-actions')).toBeTruthy()
7484
})
7585

76-
it('does not render actions when showActions is false', () => {
86+
it('does not render action icons when callbacks are not provided', () => {
7787
const mockWithoutActionsProps = {
7888
name: 'Test Vault',
7989
date: '2023-01-01',
@@ -82,8 +92,31 @@ describe('ListItem', () => {
8292

8393
const { queryByTestId } = render(<ListItem {...mockWithoutActionsProps} />)
8494

85-
expect(queryByTestId('vault-actions')?.props.children[0]).toBeUndefined()
86-
expect(queryByTestId('vault-actions')?.props.children[1]).toBeUndefined()
87-
expect(queryByTestId('vault-actions')?.props.children[2]).toBeUndefined()
95+
const actionsContainer = queryByTestId('vault-actions')
96+
expect(actionsContainer).toBeTruthy()
97+
// When no callbacks are provided, the actions container should have no meaningful children
98+
// React filters out falsy values, so children should be undefined, null, or an array of falsy values
99+
const children = actionsContainer.props.children
100+
const hasNoChildren =
101+
!children ||
102+
(Array.isArray(children) && children.every((child) => !child)) ||
103+
children === null
104+
expect(hasNoChildren).toBeTruthy()
105+
})
106+
107+
it('renders CheckIcon when isSelected is true', () => {
108+
const { getByTestId } = render(
109+
<ListItem {...mockProps} isSelected={true} />
110+
)
111+
112+
expect(getByTestId('selected-icon-container')).toBeTruthy()
113+
})
114+
115+
it('renders correctly when isLoading is true', () => {
116+
const { getByTestId } = render(<ListItem {...mockProps} isLoading={true} />)
117+
118+
// Component should still render name and date when loading
119+
expect(getByTestId('vault-name').props.children).toBe('Test Vault')
120+
expect(getByTestId('vault-date')).toBeTruthy()
88121
})
89122
})

src/screens/Settings/TabImport/utils/readFileContent.test.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe('readFileContent', () => {
2828
const result = await readFileContent(['.csv'])
2929

3030
expect(DocumentPicker.getDocumentAsync).toHaveBeenCalledWith({
31-
type: ['text/csv']
31+
type: ['text/csv', 'text/comma-separated-values']
3232
})
3333
expect(FileSystem.readAsStringAsync).toHaveBeenCalledWith(
3434
'file://test.csv',
@@ -72,7 +72,12 @@ describe('readFileContent', () => {
7272
const result = await readFileContent(['.csv', '.json', 'text/plain'])
7373

7474
expect(DocumentPicker.getDocumentAsync).toHaveBeenCalledWith({
75-
type: ['text/csv', 'application/json', 'text/plain']
75+
type: [
76+
'text/csv',
77+
'text/comma-separated-values',
78+
'application/json',
79+
'text/plain'
80+
]
7681
})
7782
expect(result).toEqual({
7883
fileContent: 'plain text',

0 commit comments

Comments
 (0)