Skip to content

Commit 2e89b71

Browse files
committed
test system now works
1 parent 9f81031 commit 2e89b71

File tree

11 files changed

+53
-23
lines changed

11 files changed

+53
-23
lines changed

__mocks__/___random-js.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// export default () => {};

__mocks__/___react-native-stylable.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default (name, comp) => {
2+
console.log(name, comp)
3+
};

package.json

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,27 +85,32 @@
8585
"ts-jest": "^22.4.1",
8686
"tslint": "^5.8.0",
8787
"tslint-react": "^3.2.0",
88-
"typescript": "^2.6.1"
88+
"typescript": "^2.7.2"
8989
},
9090
"jest": {
9191
"preset": "react-native",
92+
"transform": {
93+
"^.+\\.tsx?$": "ts-jest"
94+
},
95+
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
9296
"moduleFileExtensions": [
9397
"ts",
9498
"tsx",
95-
"js"
99+
"js",
100+
"jsx",
101+
"json",
102+
"node"
96103
],
97-
"transform": {
98-
"^.+\\.(js)$": "<rootDir>/node_modules/babel-jest",
99-
"\\.(ts|tsx)$": "ts-jest"
100-
},
101-
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
102104
"testPathIgnorePatterns": [
103-
"\\.snap$",
104-
"<rootDir>/node_modules/",
105-
"<rootDir>/lib/"
105+
"/node_modules/",
106+
"/lib/"
106107
],
107108
"transformIgnorePatterns": [
108-
"node_modules/(?!(jest-)?react-native|react-navigation|react-clone-referenced-element)"
109+
"node_modules/(?!(jest-)?react-native|react-navigation|static-container|react-native-stylable|react-clone-referenced-element)"
110+
],
111+
"roots": [
112+
"node_modules",
113+
"src"
109114
],
110115
"moduleDirectories": [
111116
"node_modules",
@@ -116,6 +121,9 @@
116121
"tsConfigFile": "tsconfig.json"
117122
}
118123
},
119-
"cacheDirectory": ".jest/cache"
124+
"cacheDirectory": ".jest/cache",
125+
"setupFiles": [
126+
"./test-setup.js"
127+
]
120128
}
121129
}

src/constants.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ export const DEFAULT_PAGE = 'default_page';
66
export const DEFAULT_TITLE = 'Home';
77

88

9-
enum NAV {
10-
AUTH = 'AUTH',
11-
MAIN = 'MAIN'
9+
export const NAV = {
10+
AUTH: 'AUTH',
11+
MAIN: 'MAIN'
1212
}
1313

1414
export const navTypes = {
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
import { applicationWatcher } from '../saga';
1+
// import { applicationWatcher } from '../saga';
22

3+
4+
// jest.mock('../../navigator/reducer');
5+
6+
import {some} from '../files';
37
describe('applicationWatcher', () => {
48
it('qwe', () => {
5-
const iterator = applicationWatcher();
9+
const iterator = some(12);
10+
11+
// const iterator = applicationWatcher();
612

7-
expect(iterator.next().value).toEqual({});
13+
// expect(iterator.next().value).toEqual({});
814
})
915
})

src/modules/application/files.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// import * as auth from 'modules/auth';
2+
import * as page from 'modules/page';
3+
// import * as account from 'modules/account';
4+
// import * as navigator from 'modules/navigator';
5+
6+
7+
console.log(page);
8+
9+
export const some = () => true;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default () => { };

src/navigatorConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
StackNavigatorConfig,
55
NavigationStackScreenOptions
66
} from 'react-navigation';
7-
import { navTypes } from './constants';
7+
import { navTypes, NAV } from './constants';
88

99
import { Colors, Fonts, FontSizes } from 'components/ui/theme';
1010
import BackgroundImageHoc from 'components/utils/BackgroundImageHoc';

src/utils/keyring.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import * as CryptoJS from 'crypto-js';
1818
import * as KJUR from 'jsrsasign';
19-
import * as Random from 'random-js';
19+
const Random = require('random-js');
2020
// import { Int64BE, Uint64BE } from 'int64-buffer';
2121

2222
// https://github.com/bitcoin/bips/blob/master/bip-0039/bip-0039-wordlists.md

test-setup.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Mock navigator reducer for all tests.
2+
jest.mock('./src/modules/navigator/reducer');

0 commit comments

Comments
 (0)