Skip to content

Commit 8728b8e

Browse files
author
Gang Wang
authored
Merge pull request #7 from wagng/unit-test
Unit test
2 parents aa25abc + e5e0d1b commit 8728b8e

File tree

15 files changed

+876
-84
lines changed

15 files changed

+876
-84
lines changed

.babelrc

Lines changed: 0 additions & 8 deletions
This file was deleted.

.circleci/config.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#
2+
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
3+
#
4+
version: 2
5+
jobs:
6+
build:
7+
docker:
8+
- image: circleci/node:8.10.0
9+
10+
working_directory: ~/repo
11+
12+
steps:
13+
- checkout
14+
15+
# Download and cache dependencies
16+
- restore_cache:
17+
keys:
18+
- v1-dependencies-{{ checksum "package.json" }}
19+
# fallback to using the latest cache if no exact match is found
20+
- v1-dependencies-
21+
22+
- run: yarn install
23+
24+
- save_cache:
25+
paths:
26+
- node_modules
27+
key: v1-dependencies-{{ checksum "package.json" }}
28+
29+
# run tests!
30+
- run: yarn test

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
./**/tests/*.js
22
*.test.js
33
./**/__tests__/**/*.js
4+
__mocks__/**/*.js
5+
jest-setup.js
6+
babel.config.js

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@ buck-out/
5252
*/fastlane/report.xml
5353
*/fastlane/Preview.html
5454
*/fastlane/screenshots
55+
.jest-cache

App.js

Lines changed: 0 additions & 27 deletions
This file was deleted.

__mocks__/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
jest
2+
.mock('react-native-navigation', () => require.requireActual('./react-native-navigation'));
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const Navigation = {
2+
registerComponent: () => Promise.resolve()
3+
};

__tests__/App.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

babel.config.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// {
2+
// "presets": ["env", "module:metro-react-native-babel-preset"],
3+
// "plugins": [
4+
// ["@babel/plugin-proposal-decorators", { "legacy": true }],
5+
// "@babel/plugin-syntax-export-namespace-from",
6+
// "transform-export-extensions"
7+
// ]
8+
// }
9+
'use strict'
10+
11+
module.exports = {
12+
presets: ["env", "@babel/preset-env", "module:metro-react-native-babel-preset"],
13+
plugins: [
14+
"@babel/plugin-transform-modules-commonjs",
15+
["@babel/plugin-proposal-decorators", { "legacy": true }],
16+
"@babel/plugin-syntax-export-namespace-from",
17+
"transform-export-extensions"
18+
],
19+
};

jest-setup.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import './__mocks__';
2+
3+
jest
4+
.mock('Button', () => {
5+
const RealComponent = require.requireActual('react-native-elements').Button;
6+
return RealComponent;
7+
});
8+
9+
const emptyFn = () => {};
10+
const AnimatedValue = function() {
11+
this.setValue = emptyFn;
12+
this.setOffset = emptyFn;
13+
};
14+
15+
const AnimatedValueXY = function() {};
16+
AnimatedValueXY.prototype.x = new AnimatedValue();
17+
AnimatedValueXY.prototype.y = new AnimatedValue();
18+
19+
console.error = jest.genMockFunction();
20+
21+
jest.resetModules();

0 commit comments

Comments
 (0)