diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..e30aa2cf --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +version: 2 +updates: + - package-ecosystem: 'npm' + directory: '/' + schedule: + interval: 'daily' + time: '21:00' + open-pull-requests-limit: 20 + ignore: + - dependency-name: 'react-native' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..9ef54c25 --- /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 jest \ 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..72f6727e 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@types/redux-logger": "^3.0.7", "@types/redux-saga": "^0.10.5", "@typescript-eslint/eslint-plugin": "^3.7.0", - "@typescript-eslint/parser": "^3.7.0", + "@typescript-eslint/parser": "^3.10.1", "babel-eslint": "^10.1.0", "babel-jest": "~25.1.0", "chalk": "^4.1.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..ed1280da 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1879,6 +1879,17 @@ eslint-scope "^5.0.0" eslint-utils "^2.0.0" +"@typescript-eslint/experimental-utils@3.10.1": + version "3.10.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-3.10.1.tgz#e179ffc81a80ebcae2ea04e0332f8b251345a686" + integrity sha512-DewqIgscDzmAfd5nOGe4zm6Bl7PKtMG2Ad0KG8CUZAHlXfAKTF9Ol5PXhiMh39yRL2ChRH1cuuUGOcVyyrhQIw== + dependencies: + "@types/json-schema" "^7.0.3" + "@typescript-eslint/types" "3.10.1" + "@typescript-eslint/typescript-estree" "3.10.1" + eslint-scope "^5.0.0" + eslint-utils "^2.0.0" + "@typescript-eslint/experimental-utils@3.7.0": version "3.7.0" resolved "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.7.0.tgz#0ee21f6c48b2b30c63211da23827725078d5169a" @@ -1898,16 +1909,22 @@ "@typescript-eslint/typescript-estree" "2.34.0" eslint-visitor-keys "^1.1.0" -"@typescript-eslint/parser@^3.7.0": - version "3.7.0" - resolved "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-3.7.0.tgz#3e9cd9df9ea644536feb6e5acdb8279ecff96ce9" +"@typescript-eslint/parser@^3.10.1": + version "3.10.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-3.10.1.tgz#1883858e83e8b442627e1ac6f408925211155467" + integrity sha512-Ug1RcWcrJP02hmtaXVS3axPPTTPnZjupqhgj+NnZ6BCkwSImWk/283347+x9wN+lqOdK9Eo3vsyiyDHgsmiEJw== dependencies: "@types/eslint-visitor-keys" "^1.0.0" - "@typescript-eslint/experimental-utils" "3.7.0" - "@typescript-eslint/types" "3.7.0" - "@typescript-eslint/typescript-estree" "3.7.0" + "@typescript-eslint/experimental-utils" "3.10.1" + "@typescript-eslint/types" "3.10.1" + "@typescript-eslint/typescript-estree" "3.10.1" eslint-visitor-keys "^1.1.0" +"@typescript-eslint/types@3.10.1": + version "3.10.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-3.10.1.tgz#1d7463fa7c32d8a23ab508a803ca2fe26e758727" + integrity sha512-+3+FCUJIahE9q0lDi1WleYzjCwJs5hIsbugIgnbB+dSCYUxl8L6PwmsyOPFZde2hc1DlTo/xnkOgiTLSyAbHiQ== + "@typescript-eslint/types@3.7.0": version "3.7.0" resolved "https://registry.npmjs.org/@typescript-eslint/types/-/types-3.7.0.tgz#09897fab0cb95479c01166b10b2c03c224821077" @@ -1924,6 +1941,20 @@ semver "^7.3.2" tsutils "^3.17.1" +"@typescript-eslint/typescript-estree@3.10.1": + version "3.10.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-3.10.1.tgz#fd0061cc38add4fad45136d654408569f365b853" + integrity sha512-QbcXOuq6WYvnB3XPsZpIwztBoquEYLXh2MtwVU+kO8jgYCiv4G5xrSP/1wg4tkvrEE+esZVquIPX/dxPlePk1w== + dependencies: + "@typescript-eslint/types" "3.10.1" + "@typescript-eslint/visitor-keys" "3.10.1" + debug "^4.1.1" + glob "^7.1.6" + is-glob "^4.0.1" + lodash "^4.17.15" + semver "^7.3.2" + tsutils "^3.17.1" + "@typescript-eslint/typescript-estree@3.7.0": version "3.7.0" resolved "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.7.0.tgz#66872e6da120caa4b64e6b4ca5c8702afc74738d" @@ -1937,6 +1968,13 @@ semver "^7.3.2" tsutils "^3.17.1" +"@typescript-eslint/visitor-keys@3.10.1": + version "3.10.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-3.10.1.tgz#cd4274773e3eb63b2e870ac602274487ecd1e931" + integrity sha512-9JgC82AaQeglebjZMgYR5wgmfUdUc+EitGUUMW8u2nDckaeimzW+VsoLV6FoimPv2id3VQzfjwBxEMVz08ameQ== + dependencies: + eslint-visitor-keys "^1.1.0" + "@typescript-eslint/visitor-keys@3.7.0": version "3.7.0" resolved "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-3.7.0.tgz#ac0417d382a136e4571a0b0dcfe52088cb628177"