Skip to content

Commit 2ec8d89

Browse files
authored
Fix mocks import in jestSetup.js (#1377)
1 parent 231103a commit 2ec8d89

File tree

4 files changed

+35
-26
lines changed

4 files changed

+35
-26
lines changed

jestSetup.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
jest.mock('./src/RNGestureHandlerModule');
1+
jest.mock('./src/RNGestureHandlerModule', () => require('./src/mocks'));
2+
jest.mock('./lib/commonjs/RNGestureHandlerModule', () =>
3+
require('./lib/commonjs/mocks')
4+
);
5+
jest.mock('./lib/module/RNGestureHandlerModule', () =>
6+
require('./lib/module/mocks')
7+
);
Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,5 @@
1-
import { View, ScrollView } from 'react-native';
2-
3-
const NOOP = () => {
4-
// do nothing
5-
};
1+
import Mocks from '../mocks';
62

73
export default {
8-
ScrollView,
9-
PanGestureHandler: View,
10-
attachGestureHandler: NOOP,
11-
createGestureHandler: NOOP,
12-
dropGestureHandler: NOOP,
13-
updateGestureHandler: NOOP,
14-
Direction: {
15-
RIGHT: 1,
16-
LEFT: 2,
17-
UP: 4,
18-
DOWN: 8,
19-
},
20-
State: {
21-
BEGAN: 'BEGAN',
22-
FAILED: 'FAILED',
23-
ACTIVE: 'ACTIVE',
24-
END: 'END',
25-
UNDETERMINED: 'UNDETERMINED',
26-
},
4+
...Mocks,
275
};

src/mocks.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { View, ScrollView as RNScrollView } from 'react-native';
2+
import { State } from './State';
3+
import { Directions } from './Directions';
4+
5+
const NOOP = () => {
6+
// do nothing
7+
};
8+
const ScrollView = RNScrollView;
9+
const PanGestureHandler = View;
10+
const attachGestureHandler = NOOP;
11+
const createGestureHandler = NOOP;
12+
const dropGestureHandler = NOOP;
13+
const updateGestureHandler = NOOP;
14+
15+
export default {
16+
ScrollView,
17+
PanGestureHandler,
18+
attachGestureHandler,
19+
createGestureHandler,
20+
dropGestureHandler,
21+
updateGestureHandler,
22+
// probably can be removed
23+
Directions,
24+
State,
25+
} as const;

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@
1818
"noUnusedParameters": true,
1919
"noUnusedLocals": true
2020
},
21-
"include": ["src/**/*.ts", "src/**/*.tsx"]
21+
"include": ["src/**/*.ts", "src/**/*.tsx", "jestSetup.js"]
2222
}

0 commit comments

Comments
 (0)