Skip to content

Commit e56a05c

Browse files
refactor: convert remaining tests to TypeScript (#3655)
1 parent 7dd70d7 commit e56a05c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+132
-80
lines changed

src/components/__tests__/ActivityIndicator.test.js renamed to src/components/__tests__/ActivityIndicator.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react';
22

33
import renderer from 'react-test-renderer';
44

5-
import ActivityIndicator from '../ActivityIndicator.tsx';
5+
import ActivityIndicator from '../ActivityIndicator';
66

77
it('renders indicator', () => {
88
const tree = renderer.create(<ActivityIndicator animating />).toJSON();

src/components/__tests__/Avatar.test.js renamed to src/components/__tests__/Avatar.test.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { fireEvent, render } from '@testing-library/react-native';
55
import renderer from 'react-test-renderer';
66

77
import { red500 } from '../../styles/themes/v2/colors';
8-
import * as Avatar from '../Avatar/Avatar.tsx';
8+
import * as Avatar from '../Avatar/Avatar';
99

1010
const styles = StyleSheet.create({
1111
bgColor: {
@@ -57,7 +57,7 @@ it('renders avatar with icon and custom background color', () => {
5757

5858
it('renders avatar with image', () => {
5959
const tree = renderer
60-
.create(<Avatar.Image source={{ src: 'avatar.png' }} />)
60+
.create(<Avatar.Image source={{ uri: 'avatar.png' }} />)
6161
.toJSON();
6262

6363
expect(tree).toMatchSnapshot();
@@ -70,6 +70,7 @@ describe('AvatarImage listener', () => {
7070
const { getByTestId } = render(
7171
<Avatar.Image
7272
testID={'avatar-image'}
73+
source={{ uri: 'avatar.png' }}
7374
onError={onListenerMock}
7475
onLayout={onListenerMock}
7576
onLoad={onListenerMock}
@@ -86,6 +87,7 @@ describe('AvatarImage listener', () => {
8687
const { getByTestId } = render(
8788
<Avatar.Image
8889
testID={'avatar-image'}
90+
source={{ uri: 'avatar.png' }}
8991
onError={onListenerMock}
9092
onLayout={onListenerMock}
9193
onLoad={onListenerMock}
@@ -102,6 +104,7 @@ describe('AvatarImage listener', () => {
102104
const { getByTestId } = render(
103105
<Avatar.Image
104106
testID={'avatar-image'}
107+
source={{ uri: 'avatar.png' }}
105108
onError={onListenerMock}
106109
onLayout={onListenerMock}
107110
onLoad={onListenerMock}
@@ -118,6 +121,7 @@ describe('AvatarImage listener', () => {
118121
const { getByTestId } = render(
119122
<Avatar.Image
120123
testID={'avatar-image'}
124+
source={{ uri: 'avatar.png' }}
121125
onError={onListenerMock}
122126
onLayout={onListenerMock}
123127
onLoad={onListenerMock}
@@ -134,6 +138,7 @@ describe('AvatarImage listener', () => {
134138
const { getByTestId } = render(
135139
<Avatar.Image
136140
testID={'avatar-image'}
141+
source={{ uri: 'avatar.png' }}
137142
onError={onListenerMock}
138143
onLayout={onListenerMock}
139144
onLoad={onListenerMock}
@@ -150,6 +155,7 @@ describe('AvatarImage listener', () => {
150155
const { getByTestId } = render(
151156
<Avatar.Image
152157
testID={'avatar-image'}
158+
source={{ uri: 'avatar.png' }}
153159
onError={onListenerMock}
154160
onLayout={onListenerMock}
155161
onLoad={onListenerMock}

src/components/__tests__/Badge.test.js renamed to src/components/__tests__/Badge.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as React from 'react';
33
import renderer from 'react-test-renderer';
44

55
import { red500 } from '../../styles/themes/v2/colors';
6-
import Badge from '../Badge.tsx';
6+
import Badge from '../Badge';
77

88
jest.mock('react-native', () => {
99
const RN = jest.requireActual('react-native');

src/components/__tests__/Checkbox/CheckboxItem.test.js renamed to src/components/__tests__/Checkbox/CheckboxItem.test.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,12 @@ it('should have `accessibilityState={ checked: false }` when `status="indetermin
8080

8181
it('disables the row when the prop disabled is true', () => {
8282
const { getByLabelText } = render(
83-
<Checkbox.Item accessibilityLabel="some checkbox" disabled />
83+
<Checkbox.Item
84+
status="unchecked"
85+
label=""
86+
accessibilityLabel="some checkbox"
87+
disabled
88+
/>
8489
);
8590

8691
const touchable = getByLabelText('some checkbox');

src/components/__tests__/Checkbox/utils.test.js renamed to src/components/__tests__/Checkbox/utils.test.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ describe('getAndroidSelectionControlColor - ripple color', () => {
1212
getAndroidSelectionControlColor({
1313
theme: getTheme(),
1414
disabled: true,
15+
checked: false,
1516
})
1617
).toMatchObject({
1718
rippleColor: color(getTheme().colors.onSurface)
@@ -26,6 +27,7 @@ describe('getAndroidSelectionControlColor - ripple color', () => {
2627
getAndroidSelectionControlColor({
2728
theme: getTheme(false, false),
2829
disabled: true,
30+
checked: false,
2931
})
3032
).toMatchObject({
3133
rippleColor: color(getTheme(false, false).colors.text)
@@ -40,6 +42,7 @@ describe('getAndroidSelectionControlColor - ripple color', () => {
4042
getAndroidSelectionControlColor({
4143
theme: getTheme(),
4244
customColor: 'purple',
45+
checked: false,
4346
})
4447
).toMatchObject({
4548
rippleColor: color('purple').fade(0.32).rgb().string(),
@@ -50,6 +53,7 @@ describe('getAndroidSelectionControlColor - ripple color', () => {
5053
expect(
5154
getAndroidSelectionControlColor({
5255
theme: getTheme(),
56+
checked: false,
5357
})
5458
).toMatchObject({
5559
rippleColor: color(getTheme().colors.primary).fade(0.32).rgb().string(),
@@ -60,6 +64,7 @@ describe('getAndroidSelectionControlColor - ripple color', () => {
6064
expect(
6165
getAndroidSelectionControlColor({
6266
theme: getTheme(false, false),
67+
checked: false,
6368
})
6469
).toMatchObject({
6570
rippleColor: color(getTheme(false, false).colors.accent)
@@ -76,6 +81,7 @@ describe('getAndroidSelectionControlColor - checkbox color', () => {
7681
getAndroidSelectionControlColor({
7782
theme: getTheme(),
7883
disabled: true,
84+
checked: false,
7985
})
8086
).toMatchObject({
8187
selectionControlColor: getTheme().colors.onSurfaceDisabled,
@@ -87,6 +93,7 @@ describe('getAndroidSelectionControlColor - checkbox color', () => {
8793
getAndroidSelectionControlColor({
8894
theme: getTheme(false, false),
8995
disabled: true,
96+
checked: false,
9097
})
9198
).toMatchObject({
9299
selectionControlColor: getTheme(false, false).colors.text,
@@ -270,7 +277,6 @@ describe('getSelectionControlIOSColor - checked color', () => {
270277
expect(
271278
getSelectionControlIOSColor({
272279
theme: getTheme(),
273-
checked: true,
274280
customColor: 'purple',
275281
})
276282
).toMatchObject({
@@ -282,7 +288,6 @@ describe('getSelectionControlIOSColor - checked color', () => {
282288
expect(
283289
getSelectionControlIOSColor({
284290
theme: getTheme(),
285-
checked: true,
286291
})
287292
).toMatchObject({
288293
checkedColor: getTheme().colors.primary,
@@ -293,7 +298,6 @@ describe('getSelectionControlIOSColor - checked color', () => {
293298
expect(
294299
getSelectionControlIOSColor({
295300
theme: getTheme(false, false),
296-
checked: true,
297301
})
298302
).toMatchObject({
299303
checkedColor: getTheme(false, false).colors.accent,

src/components/__tests__/DataTable.test.js renamed to src/components/__tests__/DataTable.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as React from 'react';
33
import { render } from '@testing-library/react-native';
44
import renderer from 'react-test-renderer';
55

6-
import DataTable from '../DataTable/DataTable.tsx';
6+
import DataTable from '../DataTable/DataTable';
77

88
it('renders data table header', () => {
99
const tree = renderer

0 commit comments

Comments
 (0)