Skip to content

Commit

Permalink
Lint and run tests as part of yarn prepare to improve safety (#2038)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsource authored Oct 11, 2022
1 parent 11470ab commit 8091c5f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
__tests__
node_modules
*.js
*.d.ts
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
clearMocks: true,
coverageDirectory: 'coverage',
moduleDirectories: ['node_modules', 'src'],
modulePathIgnorePatterns: ['IapExample'],
modulePathIgnorePatterns: ['IapExample', 'lib'],
preset: 'react-native',
setupFiles: ['<rootDir>/test/mocks/react-native-modules.js'],
setupFilesAfterEnv: ['@testing-library/jest-native/extend-expect'],
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"!**/__mocks__"
],
"scripts": {
"prepare": "bob build",
"prepare": "yarn lint && yarn test && yarn build",
"build": "bob build",
"release": "release-it",
"example": "yarn --cwd IapExample",
"test": "jest",
Expand Down
15 changes: 7 additions & 8 deletions src/__tests__/iap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ import {NativeModules} from 'react-native';

import {initConnection} from '../iap';

const rnLib = '../../node_modules/react-native/Libraries';
jest.mock(
'../../node_modules/react-native/Libraries/Utilities/Platform',
() => ({
OS: 'android',
select: (dict: {[x: string]: any}) => dict.android,
}),
);

describe('Google Play IAP', () => {
beforeEach(() => {
jest.mock(rnLib + '/Utilities/Platform', () => ({
OS: 'android',
select: (dict: {[x: string]: any}) => dict.android,
}));
});

it("should call init on Google Play's native module but not on Amazon's", async () => {
await initConnection();
expect(NativeModules.RNIapModule.initConnection).toBeCalled();
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"skipLibCheck": true,
"strict": true,
"target": "esnext"
}
},
"exclude": ["IapExample", "lib"]
}

0 comments on commit 8091c5f

Please sign in to comment.