Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BANG88 committed Nov 5, 2018
1 parent 6b04ee9 commit 5da0863
Show file tree
Hide file tree
Showing 79 changed files with 1,412 additions and 3,496 deletions.
42 changes: 0 additions & 42 deletions .babelrc

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ coverage
/es/
package-lock.json
.cdnkey
.jest
22 changes: 18 additions & 4 deletions .jest.native.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const libDir = process.env.LIB_DIR;
const { defaults: tsjPreset } = require('ts-jest/presets');

const transformPackages = [
'react-native',
Expand All @@ -10,6 +11,7 @@ const transformPackages = [
]

module.exports = {
...tsjPreset,
preset: 'react-native',
setupFiles: [
'./tests/setup.native.js'
Expand All @@ -31,16 +33,28 @@ module.exports = {
'site',
],
transform: {
'\\.tsx?$': './node_modules/antd-tools/lib/jest/codePreprocessor',
'\\.js$': './node_modules/antd-tools/lib/jest/codePreprocessor',
'\\.png': '<rootDir>/tests/imageStub.js',
// '\\.tsx?$': 'ts-jest',
...tsjPreset.transform,
// '\\.tsx?$': './node_modules/antd-tools/lib/jest/codePreprocessor',
// '\\.js$': './node_modules/antd-tools/lib/jest/codePreprocessor',
"^.+\\.js$": "<rootDir>/node_modules/react-native/jest/preprocessor.js",
"^\\.\\./style/images/(\d+)\\.png$": '<rootDir>/tests/imageStub.js',
},
testRegex: libDir === 'dist' ? 'demo\\.test\\.native\\.js$' : '.*\\.test\\.native\\.js$',
// testRegex: libDir === 'dist' ? 'demo\\.test\\.native\\.js$' : '.*\\.test\\.native\\.js$',
collectCoverageFrom: [
'components/**/*.native.{ts,tsx}',
'!components/*/style/*.{ts,tsx}',
],
transformIgnorePatterns: [
`node_modules/(?!(${transformPackages.join('|')})/)`,
],

globals: {
'ts-jest': {
babelConfig: true,
}
},
// This is the only part which you can keep
// from the above linked tutorial's config:
cacheDirectory: '.jest/cache',
};
37 changes: 37 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module.exports = {
env: {
development: {
presets: ['module:metro-react-native-babel-preset'],
plugins: [[
'import',
{libraryName: 'antd-mobile-rn', libraryDirectory: 'components'}
]]
},
production: {
presets: ['module:metro-react-native-babel-preset'],

plugins: [[
'import',
{libraryName: 'antd-mobile-rn', libraryDirectory: 'components'}
]]
},
test: {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
[
'import',
{libraryName: 'antd-mobile-rn', libraryDirectory: 'components'}
],
[
'module-resolver', {
'root': ['./'],
'cwd': 'babelrc',
'extensions': ['.js', '.ios.js', '.android.js'],
'stripExtensions': ['.ios.js', '.android.js'],
'alias': {'antd-mobile-rn': './components'}
}
]
]
}
}
};
104 changes: 21 additions & 83 deletions components/accordion/__tests__/__snapshots__/demo.test.native.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,7 @@ exports[`renders ./components/accordion/demo/basic.native.tsx correctly 1`] = `
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Array [
Object {
"backgroundColor": "transparent",
},
undefined,
]
}
style={null}
>
<View
style={
Expand Down Expand Up @@ -66,10 +59,6 @@ exports[`renders ./components/accordion/demo/basic.native.tsx correctly 1`] = `
}
>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
style={
Object {
"color": "#000000",
Expand All @@ -89,7 +78,11 @@ exports[`renders ./components/accordion/demo/basic.native.tsx correctly 1`] = `
}
>
<Image
source={1}
source={
Object {
"testUri": "../../../components/accordion/style/assets/down.png",
}
}
style={
Object {
"height": 12,
Expand Down Expand Up @@ -132,14 +125,7 @@ exports[`renders ./components/accordion/demo/basic.native.tsx correctly 1`] = `
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Array [
Object {
"backgroundColor": "transparent",
},
undefined,
]
}
style={null}
>
<View
style={
Expand Down Expand Up @@ -184,10 +170,6 @@ exports[`renders ./components/accordion/demo/basic.native.tsx correctly 1`] = `
}
>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Array [
Expand All @@ -214,14 +196,7 @@ exports[`renders ./components/accordion/demo/basic.native.tsx correctly 1`] = `
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Array [
Object {
"backgroundColor": "transparent",
},
undefined,
]
}
style={null}
>
<View
style={
Expand Down Expand Up @@ -266,10 +241,6 @@ exports[`renders ./components/accordion/demo/basic.native.tsx correctly 1`] = `
}
>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Array [
Expand All @@ -296,14 +267,7 @@ exports[`renders ./components/accordion/demo/basic.native.tsx correctly 1`] = `
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Array [
Object {
"backgroundColor": "transparent",
},
undefined,
]
}
style={null}
>
<View
style={
Expand Down Expand Up @@ -348,10 +312,6 @@ exports[`renders ./components/accordion/demo/basic.native.tsx correctly 1`] = `
}
>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Array [
Expand Down Expand Up @@ -400,14 +360,7 @@ exports[`renders ./components/accordion/demo/basic.native.tsx correctly 1`] = `
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Array [
Object {
"backgroundColor": "transparent",
},
undefined,
]
}
style={null}
>
<View
style={
Expand Down Expand Up @@ -435,10 +388,6 @@ exports[`renders ./components/accordion/demo/basic.native.tsx correctly 1`] = `
}
>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
style={
Object {
"color": "#000000",
Expand All @@ -458,7 +407,11 @@ exports[`renders ./components/accordion/demo/basic.native.tsx correctly 1`] = `
}
>
<Image
source={1}
source={
Object {
"testUri": "../../../components/accordion/style/assets/down.png",
}
}
style={
Object {
"height": 12,
Expand Down Expand Up @@ -493,10 +446,6 @@ exports[`renders ./components/accordion/demo/basic.native.tsx correctly 1`] = `
}
>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
style={
Object {
"color": "#333333",
Expand All @@ -520,14 +469,7 @@ exports[`renders ./components/accordion/demo/basic.native.tsx correctly 1`] = `
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Array [
Object {
"backgroundColor": "transparent",
},
undefined,
]
}
style={null}
>
<View
style={
Expand Down Expand Up @@ -555,10 +497,6 @@ exports[`renders ./components/accordion/demo/basic.native.tsx correctly 1`] = `
}
>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
style={
Object {
"color": "#000000",
Expand All @@ -578,7 +516,11 @@ exports[`renders ./components/accordion/demo/basic.native.tsx correctly 1`] = `
}
>
<Image
source={1}
source={
Object {
"testUri": "../../../components/accordion/style/assets/up.png",
}
}
style={
Object {
"height": 12,
Expand Down Expand Up @@ -608,10 +550,6 @@ exports[`renders ./components/accordion/demo/basic.native.tsx correctly 1`] = `
}
>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
style={
Object {
"color": "#333333",
Expand Down
Binary file added components/accordion/style/assets/down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added components/accordion/style/assets/up.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 5da0863

Please sign in to comment.