diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..d8b3a27d --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,15 @@ +version: 2 +updates: + - package-ecosystem: npm + directory: '/' + schedule: + interval: daily + time: '21:00' + open-pull-requests-limit: 10 + ignore: + - dependency-name: typeorm + versions: + - '> 0.2.24' + - '< 0.3' + reviewers: + - 'theappnest/backend' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..327a6427 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,40 @@ +name: Git Checks + +on: [push] + +jobs: + build: + name: Run tests, linter, TS + runs-on: macOS-latest + + steps: + - name: Check out Git repository + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v1 + with: + node-version: 12 + + - name: Install dependencies + run: yarn + + - name: Pod Install + working-directory: ios + run: pod install + + # TS + - name: Run TypeScript + run: yarn tsc + + # Run linter + - name: Run linter + run: yarn lint + + # Run Prettier + - name: Run prettier + run: yarn prettier + + # Tests + - name: Run unit tests + run: yarn test \ No newline at end of file diff --git a/.github/workflows/ts-ignore-counter.yml b/.github/workflows/ts-ignore-counter.yml new file mode 100644 index 00000000..c1a00ac2 --- /dev/null +++ b/.github/workflows/ts-ignore-counter.yml @@ -0,0 +1,48 @@ +name: TypeScript '@ts-ignore' counter +on: push +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Dump GitHub context + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: echo "$GITHUB_CONTEXT" + - uses: actions/checkout@v2 + with: + ref: master + - name: Count ts-ignore on master + id: before + run: | + export BEFORE=`find . -type f \( -name "*.ts" -or -name "*.tsx" \) -exec grep -o "@ts-ignore" {} \; |wc -l` + echo "::set-output name=count::$BEFORE" + - uses: actions/checkout@v2 + - name: Count ts-ignore on this commit + id: after + run: | + export AFTER=`find . -type f \( -name "*.ts" -or -name "*.tsx" \) -exec grep -o "@ts-ignore" {} \; |wc -l` + echo "::set-output name=count::$AFTER" + - name: Do the math + id: result + run: | + export BEFORE="${{ steps.before.outputs.count }}" + export AFTER="${{ steps.after.outputs.count }}" + if [[ `expr $AFTER - $BEFORE` -gt 0 ]]; then + export DIFF=`expr $AFTER - $BEFORE` + export CHANGE="(went up by $DIFF) " + for n in $(seq $DIFF); do export CHANGE="$CHANGE:broken_heart:"; done + elif [[ `expr $BEFORE - $AFTER` -gt 0 ]]; then + export DIFF=`expr $BEFORE - $AFTER` + export CHANGE="(went down by $DIFF) " + for n in $(seq $DIFF); do export CHANGE="$CHANGE:sparkles:"; done + else + export CHANGE="(unchanged)" + fi + echo "::set-output name=comment::**ts-ignore**'s: $AFTER $CHANGE" + - name: Post issue comment + run: | + jq --arg msg "${{ steps.result.outputs.comment }}" -nc '{"body": $msg}' | \ + curl -sL -X POST -d @- \ + -H "Content-Type: application/json" \ + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + "https://api.github.com/repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA/comments" \ No newline at end of file diff --git a/__mocks__/react-native-device-info.js b/__mocks__/react-native-device-info.js new file mode 100644 index 00000000..250db168 --- /dev/null +++ b/__mocks__/react-native-device-info.js @@ -0,0 +1,32 @@ +module.exports = { + getUserAgent: () => "TestUser/Agent", + getManufacturer: () => "Apple", + getDeviceId: () => "DeviceId", + getSystemVersion: () => "10.0", + getReadableVersion: () => "1.0.0.1", + getApplicationName: () => "Mindful Chef (Dev)", + isEmulator: () => true, + isTablet: () => false, + getModel: () => "Mock iPhone 12", + getVersion: jest.fn(() => Promise.resolve("24.0")), + getBundleId: jest.fn(() => Promise.resolve("com.mindfulchef.uat")), + getBuildNumber: jest.fn(() => Promise.resolve("3.0.0")), + getIpAddress: jest.fn(() => Promise.resolve("10.158.70.93")), + getUniqueID: jest.fn(), + getBrand: jest.fn(), + getSystemName: jest.fn(), + getDeviceName: jest.fn(), + getDeviceLocale: jest.fn(), + getDeviceCountry: jest.fn(), + getTimezone: jest.fn(), + is24Hour: jest.fn(), + isPinOrFingerprintSet: jest.fn(), + getAPILevel: jest.fn(), + getInstanceID: jest.fn(), + getPhoneNumber: jest.fn(), + getFirstInstallTime: jest.fn(), + getLastUpdateTime: jest.fn(), + getSerialNumber: jest.fn(), + getMACAddress: jest.fn(), + getCarrier: jest.fn(), +}; diff --git a/__mocks__/react-native-permissions.js b/__mocks__/react-native-permissions.js new file mode 100644 index 00000000..bec05185 --- /dev/null +++ b/__mocks__/react-native-permissions.js @@ -0,0 +1,3 @@ +module.exports = { + checkNotifications: () => true, +}; diff --git a/package.json b/package.json index 40d9d570..576a4c3f 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "@typescript-eslint/eslint-plugin": "^3.7.0", "@typescript-eslint/parser": "^3.7.0", "babel-eslint": "^10.1.0", - "babel-jest": "~25.1.0", + "babel-jest": "~26.6.3", "chalk": "^4.1.0", "eslint": "^7.5.0", "eslint-config-prettier": "^6.7.0", diff --git a/src/components/__tests__/ButtonWithIcon.spec.tsx b/src/components/__tests__/ButtonWithIcon.spec.tsx index d25b5d17..e48bbdb0 100644 --- a/src/components/__tests__/ButtonWithIcon.spec.tsx +++ b/src/components/__tests__/ButtonWithIcon.spec.tsx @@ -6,7 +6,7 @@ import ButtonWithIcon from "../ButtonWithIcon"; it(`renders correctly`, () => { const defaultProps = { label: "Google", - icon: "Icon", + icon: "add", onPress: () => {}, }; const tree = renderer.create().toJSON(); diff --git a/src/components/__tests__/__snapshots__/ButtonWithIcon.spec.tsx.snap b/src/components/__tests__/__snapshots__/ButtonWithIcon.spec.tsx.snap index 210075f4..d7946203 100644 --- a/src/components/__tests__/__snapshots__/ButtonWithIcon.spec.tsx.snap +++ b/src/components/__tests__/__snapshots__/ButtonWithIcon.spec.tsx.snap @@ -72,7 +72,7 @@ exports[`renders correctly 1`] = ` ] } > - ? +  + Google.com + + -  + , , - - Google.com - - - , , - + "alignItems": "center", + "backgroundColor": "#f7f7f7", + "flex": 1, + "height": 100, + "justifyContent": "center", + "width": 100, + } + } + > + +  + + + `; diff --git a/src/screens/__tests__/__snapshots__/SettingsScreen.spec.tsx.snap b/src/screens/__tests__/__snapshots__/SettingsScreen.spec.tsx.snap new file mode 100644 index 00000000..45b807ca --- /dev/null +++ b/src/screens/__tests__/__snapshots__/SettingsScreen.spec.tsx.snap @@ -0,0 +1,501 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`SettingsScreen renders the SettingsScreen screen 1`] = ` + + + + + + + Your details + + + + + + + Name + + + John + + Doe + + + + + Email + + + test@test.com + + + + + App version + + + + + + + + UUID + + + + + + + + + + + + +  + + + + Terms & Conditions + + + + + + + + +  + + + + Contact + + + + + + + + +  + + + + Logout + + + + + + +`; diff --git a/src/store/reducers/__tests__/data.spec.tsx b/src/store/reducers/__tests__/data.spec.tsx index 2b6fe68a..16ef6f05 100644 --- a/src/store/reducers/__tests__/data.spec.tsx +++ b/src/store/reducers/__tests__/data.spec.tsx @@ -9,7 +9,6 @@ describe("Data reducer", () => { }); expect(state).toEqual({ - data: [], universities: [], }); }); @@ -22,7 +21,7 @@ describe("Data reducer", () => { payload, }); - expect(state).toEqual({ data: [], universities: ["mock"] }); + expect(state).toEqual({ universities: ["mock"] }); }); it("DATA_FETCHED_FAILURE", () => { @@ -33,6 +32,6 @@ describe("Data reducer", () => { payload, }); - expect(state).toEqual({ data: [], universities: [] }); + expect(state).toEqual({ universities: [] }); }); }); diff --git a/yarn.lock b/yarn.lock index 36ed8e43..5438a725 100644 --- a/yarn.lock +++ b/yarn.lock @@ -207,6 +207,11 @@ version "7.10.4" resolved "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.10.4.tgz#2f75a831269d4f677de49986dff59927533cf375" +"@babel/helper-plugin-utils@^7.12.13": + version "7.13.0" + resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.13.0.tgz#806526ce125aed03373bc416a828321e3a6a33af" + integrity sha512-ZPafIPSwzUlAoWT8DKs1W2VyF2gOWthGd5NGFMsBcMMol+ZhK+EQY/e6V96poa6PA/Bh+C9plWN0hXO1uB8AfQ== + "@babel/helper-regex@^7.10.4": version "7.10.5" resolved "https://registry.npmjs.org/@babel/helper-regex/-/helper-regex-7.10.5.tgz#32dfbb79899073c415557053a19bd055aae50ae0" @@ -455,6 +460,13 @@ dependencies: "@babel/helper-plugin-utils" "^7.8.0" +"@babel/plugin-syntax-top-level-await@^7.8.3": + version "7.12.13" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.12.13.tgz#c5f0fa6e249f5b739727f923540cf7a806130178" + integrity sha512-A81F9pDwyS7yM//KwbCSDqy3Uj4NMIurtplxphWxoYtNPov7cJsDkAFNNyVlIZ3jwGycVsurZ+LtOA8gZ376iQ== + dependencies: + "@babel/helper-plugin-utils" "^7.12.13" + "@babel/plugin-syntax-typescript@^7.10.4": version "7.10.4" resolved "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.10.4.tgz#2f55e770d3501e83af217d782cb7517d7bb34d25" @@ -1206,7 +1218,7 @@ jest-runner "^25.5.4" jest-runtime "^25.5.4" -"@jest/transform@^25.1.0", "@jest/transform@^25.5.1": +"@jest/transform@^25.5.1": version "25.5.1" resolved "https://registry.npmjs.org/@jest/transform/-/transform-25.5.1.tgz#0469ddc17699dd2bf985db55fa0fb9309f5c2db3" dependencies: @@ -1227,6 +1239,27 @@ source-map "^0.6.1" write-file-atomic "^3.0.0" +"@jest/transform@^26.6.2": + version "26.6.2" + resolved "https://registry.yarnpkg.com/@jest/transform/-/transform-26.6.2.tgz#5ac57c5fa1ad17b2aae83e73e45813894dcf2e4b" + integrity sha512-E9JjhUgNzvuQ+vVAL21vlyfy12gP0GhazGgJC4h6qUt1jSdUXGWJ1wfu/X7Sd8etSgxV4ovT1pb9v5D6QW4XgA== + dependencies: + "@babel/core" "^7.1.0" + "@jest/types" "^26.6.2" + babel-plugin-istanbul "^6.0.0" + chalk "^4.0.0" + convert-source-map "^1.4.0" + fast-json-stable-stringify "^2.0.0" + graceful-fs "^4.2.4" + jest-haste-map "^26.6.2" + jest-regex-util "^26.0.0" + jest-util "^26.6.2" + micromatch "^4.0.2" + pirates "^4.0.1" + slash "^3.0.0" + source-map "^0.6.1" + write-file-atomic "^3.0.0" + "@jest/types@^24.9.0": version "24.9.0" resolved "https://registry.npmjs.org/@jest/types/-/types-24.9.0.tgz#63cb26cb7500d069e5a389441a7c6ab5e909fc59" @@ -1235,7 +1268,7 @@ "@types/istanbul-reports" "^1.1.1" "@types/yargs" "^13.0.0" -"@jest/types@^25.1.0", "@jest/types@^25.5.0": +"@jest/types@^25.5.0": version "25.5.0" resolved "https://registry.npmjs.org/@jest/types/-/types-25.5.0.tgz#4d6a4793f7b9599fc3680877b856a97dbccf2a9d" dependencies: @@ -1244,16 +1277,7 @@ "@types/yargs" "^15.0.0" chalk "^3.0.0" -"@jest/types@^26.1.0": - version "26.1.0" - resolved "https://registry.npmjs.org/@jest/types/-/types-26.1.0.tgz#f8afaaaeeb23b5cad49dd1f7779689941dcb6057" - dependencies: - "@types/istanbul-lib-coverage" "^2.0.0" - "@types/istanbul-reports" "^1.1.1" - "@types/yargs" "^15.0.0" - chalk "^4.0.0" - -"@jest/types@^26.6.2": +"@jest/types@^26.1.0", "@jest/types@^26.6.2": version "26.6.2" resolved "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz#bef5a532030e1d88a2f5a6d933f84e97226ed48e" integrity sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ== @@ -1655,9 +1679,10 @@ merge-deep "^3.0.2" svgo "^1.2.2" -"@types/babel__core@^7.1.0", "@types/babel__core@^7.1.7": - version "7.1.9" - resolved "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.9.tgz#77e59d438522a6fb898fa43dc3455c6e72f3963d" +"@types/babel__core@^7.0.0", "@types/babel__core@^7.1.7": + version "7.1.13" + resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.13.tgz#bc6eea53975fdf163aff66c086522c6f293ae4cf" + integrity sha512-CC6amBNND16pTk4K3ZqKIaba6VGKAQs3gMjEY17FVd56oI/ZWt9OhS6riYiWv9s8ENbYUi7p8lgqb0QHQvUKQQ== dependencies: "@babel/parser" "^7.1.0" "@babel/types" "^7.0.0" @@ -2268,16 +2293,18 @@ babel-jest@^25.5.1: graceful-fs "^4.2.4" slash "^3.0.0" -babel-jest@~25.1.0: - version "25.1.0" - resolved "https://registry.npmjs.org/babel-jest/-/babel-jest-25.1.0.tgz#206093ac380a4b78c4404a05b3277391278f80fb" +babel-jest@~26.6.3: + version "26.6.3" + resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-26.6.3.tgz#d87d25cb0037577a0c89f82e5755c5d293c01056" + integrity sha512-pl4Q+GAVOHwvjrck6jKjvmGhnO3jHX/xuB9d27f+EJZ/6k+6nMuPjorrYp7s++bKKdANwzElBWnLWaObvTnaZA== dependencies: - "@jest/transform" "^25.1.0" - "@jest/types" "^25.1.0" - "@types/babel__core" "^7.1.0" + "@jest/transform" "^26.6.2" + "@jest/types" "^26.6.2" + "@types/babel__core" "^7.1.7" babel-plugin-istanbul "^6.0.0" - babel-preset-jest "^25.1.0" - chalk "^3.0.0" + babel-preset-jest "^26.6.2" + chalk "^4.0.0" + graceful-fs "^4.2.4" slash "^3.0.0" babel-messages@^6.23.0: @@ -2310,6 +2337,16 @@ babel-plugin-jest-hoist@^25.5.0: "@babel/types" "^7.3.3" "@types/babel__traverse" "^7.0.6" +babel-plugin-jest-hoist@^26.6.2: + version "26.6.2" + resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-26.6.2.tgz#8185bd030348d254c6d7dd974355e6a28b21e62d" + integrity sha512-PO9t0697lNTmcEHH69mdtYiOIkkOlj9fySqfO3K1eCcdISevLAE0xY59VLLUj0SoiPiTX/JU2CYFpILydUa5Lw== + dependencies: + "@babel/template" "^7.3.3" + "@babel/types" "^7.3.3" + "@types/babel__core" "^7.0.0" + "@types/babel__traverse" "^7.0.6" + babel-plugin-syntax-trailing-function-commas@^7.0.0-beta.0: version "7.0.0-beta.0" resolved "https://registry.npmjs.org/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-7.0.0-beta.0.tgz#aa213c1435e2bffeb6fca842287ef534ad05d5cf" @@ -2330,6 +2367,24 @@ babel-preset-current-node-syntax@^0.1.2: "@babel/plugin-syntax-optional-catch-binding" "^7.8.3" "@babel/plugin-syntax-optional-chaining" "^7.8.3" +babel-preset-current-node-syntax@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.0.1.tgz#b4399239b89b2a011f9ddbe3e4f401fc40cff73b" + integrity sha512-M7LQ0bxarkxQoN+vz5aJPsLBn77n8QgTFmo8WK0/44auK2xlCXrYcUxHFxgU7qW5Yzw/CjmLRK2uJzaCd7LvqQ== + dependencies: + "@babel/plugin-syntax-async-generators" "^7.8.4" + "@babel/plugin-syntax-bigint" "^7.8.3" + "@babel/plugin-syntax-class-properties" "^7.8.3" + "@babel/plugin-syntax-import-meta" "^7.8.3" + "@babel/plugin-syntax-json-strings" "^7.8.3" + "@babel/plugin-syntax-logical-assignment-operators" "^7.8.3" + "@babel/plugin-syntax-nullish-coalescing-operator" "^7.8.3" + "@babel/plugin-syntax-numeric-separator" "^7.8.3" + "@babel/plugin-syntax-object-rest-spread" "^7.8.3" + "@babel/plugin-syntax-optional-catch-binding" "^7.8.3" + "@babel/plugin-syntax-optional-chaining" "^7.8.3" + "@babel/plugin-syntax-top-level-await" "^7.8.3" + babel-preset-fbjs@^3.2.0, babel-preset-fbjs@^3.3.0: version "3.3.0" resolved "https://registry.npmjs.org/babel-preset-fbjs/-/babel-preset-fbjs-3.3.0.tgz#a6024764ea86c8e06a22d794ca8b69534d263541" @@ -2362,13 +2417,21 @@ babel-preset-fbjs@^3.2.0, babel-preset-fbjs@^3.3.0: "@babel/plugin-transform-template-literals" "^7.0.0" babel-plugin-syntax-trailing-function-commas "^7.0.0-beta.0" -babel-preset-jest@^25.1.0, babel-preset-jest@^25.5.0: +babel-preset-jest@^25.5.0: version "25.5.0" resolved "https://registry.npmjs.org/babel-preset-jest/-/babel-preset-jest-25.5.0.tgz#c1d7f191829487a907764c65307faa0e66590b49" dependencies: babel-plugin-jest-hoist "^25.5.0" babel-preset-current-node-syntax "^0.1.2" +babel-preset-jest@^26.6.2: + version "26.6.2" + resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-26.6.2.tgz#747872b1171df032252426586881d62d31798fee" + integrity sha512-YvdtlVm9t3k777c5NPQIv6cxFFFapys25HiUmuSgHwIZhfifweR5c5Sf5nwE3MAbfu327CYSvps8Yx6ANLyleQ== + dependencies: + babel-plugin-jest-hoist "^26.6.2" + babel-preset-current-node-syntax "^1.0.0" + babel-runtime@^6.22.0, babel-runtime@^6.26.0: version "6.26.0" resolved "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" @@ -4697,7 +4760,7 @@ jest-haste-map@^25.5.1: optionalDependencies: fsevents "^2.1.2" -jest-haste-map@^26.5.2: +jest-haste-map@^26.5.2, jest-haste-map@^26.6.2: version "26.6.2" resolved "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-26.6.2.tgz#dd7e60fe7dc0e9f911a23d79c5ff7fb5c2cafeaa" integrity sha512-easWIJXIw71B2RdR8kgqpjQrbMRWQBgiBwXYEhtGUTaX+doCjBheluShdDMeR8IMfJiTqH4+zfhtg29apJf/8w==