Skip to content

Commit

Permalink
fix tests (#383)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdlucas authored Sep 13, 2022
1 parent 2d84f0e commit 1f7f9d7
Show file tree
Hide file tree
Showing 14 changed files with 108 additions and 1,574 deletions.
2 changes: 1 addition & 1 deletion .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"**/*.ts?(x)": ["yarn pretty", "yarn lint"]
"**/*.ts?(x)": ["yarn pretty", "yarn lint", "yarn test"]
}
14 changes: 2 additions & 12 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@ module.exports = {
'@babel/preset-react',
'module:metro-react-native-babel-preset',
],
plugins: [
'transform-es2015-modules-commonjs',
'@babel/transform-flow-strip-types',
'@babel/transform-object-assign',
[
'module-resolver',
{
root: ['./src'],
extensions: ['.ios.js', '.android.js', '.js', '.json'],
},
],
],
plugins: ["@babel/plugin-proposal-class-properties"],

};
15 changes: 7 additions & 8 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
const { defaults: tsjPreset } = require('ts-jest/presets');

module.exports = {
...tsjPreset,
verbose: true,
automock: false,
collectCoverage: true,
testEnvironment: 'node',
preset: 'react-native',
transform: {
...tsjPreset.transform,
'\\.js$': '<rootDir>/node_modules/react-native/jest/preprocessor.js',
},
globals: {
'ts-jest': {
tsconfig: 'tsconfig.test.json',
babelConfig: true,
},
},
transform: {
'^.+\\.(js|jsx)$': 'babel-jest',
'^.+\\.(ts|tsx)$': 'ts-jest',
},
transformIgnorePatterns: [
'node_modules/(?!@platformbuilders|@react-native|react-native)',
],
Expand All @@ -28,9 +29,7 @@ module.exports = {
statements: 0,
},
},
setupFiles: ['<rootDir>/src/tools/test-setup.ts'],
setupFilesAfterEnv: ['./node_modules/jest-enzyme/lib/index.js'],
unmockedModulePathPatterns: ['react', 'enzyme', 'jest-enzyme'],
unmockedModulePathPatterns: ['react'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
collectCoverageFrom: ['src/**/*.{ts|tsx}', 'src/**/{!(index),}.ts'],
moduleDirectories: ['node_modules', '<rootDir>'],
Expand Down
9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"*.{ts,js}": [
"yarn pretty",
"yarn lint",
"yarn test",
"git add ."
]
},
Expand All @@ -60,11 +61,10 @@
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-transform-flow-strip-types": "^7.18.9",
"@babel/plugin-transform-object-assign": "^7.18.6",
"@babel/plugin-transform-react-jsx-source": "^7.18.6",
"@babel/preset-env": "^7.18.10",
"@babel/preset-react": "^7.18.6",
"@babel/runtime": "^7.18.9",
"@types/enzyme": "^3.10.12",
"@types/enzyme-adapter-react-16": "^1.0.6",
"@types/jest": "^28.1.6",
"@types/lodash": "^4.14.182",
"@types/numeral": "^2.0.2",
Expand All @@ -77,8 +77,6 @@
"babel-jest": "^28.1.3",
"babel-plugin-module-resolver": "^4.1.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.6",
"eslint": "^8.21.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^17.0.0",
Expand All @@ -95,7 +93,6 @@
"husky": "^8.0.1",
"jest": "^28.1.3",
"jest-environment-node": "^28.1.3",
"jest-enzyme": "^7.1.2",
"lint-staged": "^13.0.3",
"mz": "^2.7.0",
"prettier": "^2.7.1",
Expand All @@ -105,7 +102,7 @@
"rmfr": "^2.0.0",
"rollup": "^2.77.2",
"rollup-plugin-typescript2": "^0.32.1",
"ts-jest": "^28.0.7",
"ts-jest": "28.0.3",
"typescript": "^4.7.4",
"uglify-js": "^3.16.3"
}
Expand Down
12 changes: 12 additions & 0 deletions src/__tests__/formatCardNumber.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { formatCardNumber } from '../shared/formatCardNumber';

describe('formatCardNumber tests', () => {
it('should apply mask credit card number 5363 5085 9979 9238', () => {
const parsed = formatCardNumber('53 63 5 085 99 79 9238');
expect(parsed).toBe('5363 5085 9979 9238');
});
it('should apply mask credit card number 4024 0071 0360 4194', () => {
const parsed = formatCardNumber('4024007103604194');
expect(parsed).toBe('4024 0071 0360 4194');
});
});
22 changes: 0 additions & 22 deletions src/__tests__/getTheme.spec.ts

This file was deleted.

31 changes: 0 additions & 31 deletions src/__tests__/ifStyle.spec.ts

This file was deleted.

24 changes: 0 additions & 24 deletions src/__tests__/pixelToRem.spec.ts

This file was deleted.

23 changes: 0 additions & 23 deletions src/__tests__/switchStyle.spec.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/native/__tests__/getShadow.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/shared/formatCardNumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const formatCardNumber = (value: string): string => {
}

if (parts.length) {
return parts.join(' ');
return parts.join(' ');
}
return value;
};
4 changes: 0 additions & 4 deletions src/tools/test-setup.ts

This file was deleted.

28 changes: 28 additions & 0 deletions tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"isolatedModules": true,
"jsx": "react-native",
"lib": ["esnext"],
"module": "commonjs",
"moduleResolution": "node",
"noEmit": true,
"strict": true,
"target": "esnext"
},
"include": [
"src/**/*.test.ts",
"babel.config.js",
"jest.config.js"
],
"exclude": [
"node_modules",
"babel.config.js",
"metro.config.js",
"jest.config.js",
"dist",
"documentation"
]
}
Loading

0 comments on commit 1f7f9d7

Please sign in to comment.