Skip to content

Commit e04b577

Browse files
Damian SznajderDamian Sznajder
authored andcommitted
Setup fake timers for jest
1 parent 94f20ed commit e04b577

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ node_modules/
55
README.md
66
CHANGELOG.md
77
LICENCE
8+
__tests__

jest/setup.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
jest.useFakeTimers();

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
"testEnvironment": "node",
4141
"preset": "react-native",
4242
"testRegex": "/__tests__/.*\\.(test)\\.(js|tsx?)$",
43+
"setupFiles": [
44+
"./jest/setup"
45+
],
4346
"modulePathIgnorePatterns": [
4447
"<rootDir>/Example"
4548
]

src/__tests__/helpers.test.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { fillOtpCode } from '../helpers';
2+
3+
describe('fillOtpCode', () => {
4+
test('with only number of inputs', () => {
5+
expect(fillOtpCode(6)).toEqual({
6+
'0': '',
7+
'1': '',
8+
'2': '',
9+
'3': '',
10+
'4': '',
11+
'5': '',
12+
});
13+
});
14+
15+
test('with number and code', () => {
16+
expect(fillOtpCode(6, 'code')).toEqual({
17+
'0': 'c',
18+
'1': 'o',
19+
'2': 'd',
20+
'3': 'e',
21+
'4': '',
22+
'5': '',
23+
});
24+
});
25+
});

0 commit comments

Comments
 (0)