Skip to content

Commit 94f20ed

Browse files
Damian SznajderDamian Sznajder
authored andcommitted
Fix tests
1 parent f8505df commit 94f20ed

File tree

7 files changed

+145
-722
lines changed

7 files changed

+145
-722
lines changed

.eslintrc.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ module.exports = {
99
env: {
1010
browser: true,
1111
node: true,
12+
jest: true,
1213
},
1314
rules: {
15+
'jest/consistent-test-it': ['error', { fn: 'test' }],
1416
'prettier/prettier': [
1517
'error',
1618
{
@@ -22,4 +24,4 @@ module.exports = {
2224
},
2325
],
2426
},
25-
}
27+
};

Example/.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module.exports = {
99
env: {
1010
browser: true,
1111
node: true,
12+
jest: true,
1213
},
1314
rules: {
1415
'jest/consistent-test-it': ['error', { fn: 'test' }],

src/__tests__/OtpInput.test.js

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,10 @@ import renderer from 'react-test-renderer';
55
import OtpInput from '../OtpInput';
66

77
describe('<OtpInput />', () => {
8-
const defaultProps = {
9-
handleBackspace: ({ nativeEvent: {} }) => {},
10-
updateText: ({ nativeEvent: {} }) => {},
11-
};
8+
const defaultProps = {};
9+
const wrapper = renderer.create(<OtpInput {...defaultProps} />);
1210

13-
describe('render', () => {
14-
test('with default props', () => {
15-
const wrapper = renderer.create(<OtpInput {...defaultProps} />);
16-
17-
expect(wrapper).toMatchSnapshot();
18-
});
19-
20-
test('with iOS version 12 or higher', () => {
21-
const wrapper = renderer.create(<OtpInput {...defaultProps} />);
22-
expect(wrapper).toMatchSnapshot();
23-
});
24-
});
25-
26-
describe('_onFocus', () => {
27-
test('should change state of `isFocused` to true', () => {
28-
const wrapperInstance = renderer.create(<OtpInput {...defaultProps} />).getInstance();
29-
wrapperInstance.setState({ isFocused: false });
30-
wrapperInstance._onFocus();
31-
32-
expect(wrapperInstance.state.isFocused).toEqual(true);
33-
});
34-
});
35-
36-
describe('_onBlur', () => {
37-
test('should change state of `isFocused` to false', () => {
38-
const wrapperInstance = renderer.create(<OtpInput {...defaultProps} />).getInstance();
39-
wrapperInstance.setState({ isFocused: true });
40-
wrapperInstance._onBlur();
41-
42-
expect(wrapperInstance.state.isFocused).toEqual(false);
43-
});
11+
test('render', () => {
12+
expect(wrapper).toMatchSnapshot();
4413
});
4514
});

src/__tests__/__snapshots__/OtpInput.test.js.snap

Lines changed: 1 addition & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,127 +1,20 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`<OtpInput /> render with default props 1`] = `
3+
exports[`<OtpInput /> render 1`] = `
44
<View
55
style={
66
Array [
7-
Object {
8-
"borderBottomWidth": 1,
9-
"height": 53,
10-
"margin": 10,
11-
},
127
undefined,
138
false,
14-
Object {
15-
"borderColor": undefined,
16-
},
179
]
1810
}
1911
>
2012
<TextInput
2113
allowFontScaling={true}
2214
maxLength={1}
2315
onBlur={[Function]}
24-
onChange={[Function]}
2516
onFocus={[Function]}
2617
rejectResponderTermination={true}
27-
style={
28-
Array [
29-
Object {
30-
"fontSize": 24,
31-
"paddingTop": 10,
32-
"textAlign": "center",
33-
"width": 40,
34-
},
35-
undefined,
36-
undefined,
37-
]
38-
}
39-
textContentType="none"
40-
underlineColorAndroid="transparent"
41-
/>
42-
</View>
43-
`;
44-
45-
exports[`<OtpInput /> render with error message 1`] = `
46-
<View
47-
style={
48-
Array [
49-
Object {
50-
"borderBottomWidth": 1,
51-
"height": 53,
52-
"margin": 10,
53-
},
54-
undefined,
55-
false,
56-
Object {
57-
"borderColor": undefined,
58-
},
59-
]
60-
}
61-
>
62-
<TextInput
63-
allowFontScaling={true}
64-
maxLength={1}
65-
onBlur={[Function]}
66-
onChange={[Function]}
67-
onFocus={[Function]}
68-
rejectResponderTermination={true}
69-
style={
70-
Array [
71-
Object {
72-
"fontSize": 24,
73-
"paddingTop": 10,
74-
"textAlign": "center",
75-
"width": 40,
76-
},
77-
undefined,
78-
Object {
79-
"color": "#00ff00",
80-
},
81-
]
82-
}
83-
textContentType="none"
84-
underlineColorAndroid="transparent"
85-
/>
86-
</View>
87-
`;
88-
89-
exports[`<OtpInput /> render with iOS version 12 or higher 1`] = `
90-
<View
91-
style={
92-
Array [
93-
Object {
94-
"borderBottomWidth": 1,
95-
"height": 53,
96-
"margin": 10,
97-
},
98-
undefined,
99-
false,
100-
Object {
101-
"borderColor": undefined,
102-
},
103-
]
104-
}
105-
>
106-
<TextInput
107-
allowFontScaling={true}
108-
maxLength={1}
109-
onBlur={[Function]}
110-
onChange={[Function]}
111-
onFocus={[Function]}
112-
rejectResponderTermination={true}
113-
style={
114-
Array [
115-
Object {
116-
"fontSize": 24,
117-
"paddingTop": 10,
118-
"textAlign": "center",
119-
"width": 40,
120-
},
121-
undefined,
122-
undefined,
123-
]
124-
}
12518
textContentType="none"
12619
underlineColorAndroid="transparent"
12720
/>

0 commit comments

Comments
 (0)