diff --git a/.coveralls.yml b/.coveralls.yml new file mode 100644 index 00000000..f7f22796 --- /dev/null +++ b/.coveralls.yml @@ -0,0 +1,2 @@ +service_name: "github" +repo_token: $COVERALLS_REPO_TOKEN \ No newline at end of file diff --git a/.env.example b/.env.example index db12b357..452aa654 100644 --- a/.env.example +++ b/.env.example @@ -37,4 +37,6 @@ GOOGLE_CALLBACK_URL = "" # CLOUDINARY CONFIGURATION CLOUDINARY_NAME="" CLOUDINARY_KEY="" -CLOUDINARY_SECRET="" \ No newline at end of file +CLOUDINARY_SECRET="" + +COVERALLS_REPO_TOKEN="" \ No newline at end of file diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index d11561a2..e208b17c 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -29,6 +29,10 @@ jobs: DB_USER: ${{ secrets.DEV_DB_USER }} DB_PASSWORD: ${{ secrets.DEV_DB_PASSWORD }} DB_HOST: ${{ secrets.DEV_DB_HOST }} + - name: Send Coverage to Coveralls + uses: coverallsapp/github-action@v2.2.3 + with: + github-token: ${{ secrets.COVERALLS_REPO_TOKEN }} build: name: Build diff --git a/README.md b/README.md index 78c4122e..f51af7c4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,17 @@ [![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com) +[![.github/workflows/main.yaml](https://github.com/atlp-rwanda/e-commerce-mavericcks-bn/actions/workflows/main.yaml/badge.svg)](https://github.com/atlp-rwanda/e-commerce-mavericcks-bn/actions/workflows/main.yaml) +[![Coverage Status](https://coveralls.io/repos/github/atlp-rwanda/e-commerce-mavericcks-bn/badge.svg?develop)](https://github.com/atlp-rwanda/e-commerce-mavericcks-bn.git) [![Version](https://img.shields.io/badge/version-1.0.0-blue)](https://github.com/your-username/your-repo-name/releases/tag/v1.0.0) ![Code Climate maintainability](https://img.shields.io/codeclimate/maintainability-percentage/atlp-rwanda/e-commerce-mavericcks-bn) + + + +![NodeJS](https://img.shields.io/badge/node.js-6DA55F?style=for-the-badge&logo=node.js&logoColor=white) ![Express.js](https://img.shields.io/badge/express.js-%23404d59.svg?style=for-the-badge&logo=express&logoColor=%2361DAFB) ![Static Badge](https://img.shields.io/badge/Sequelize-blue?style=for-the-badge&logo=nodedotjs&logoColor=white) ![Static Badge](https://img.shields.io/badge/Docker-%23095CB0?style=for-the-badge&logo=docker&logoColor=white) ![Static Badge](https://img.shields.io/badge/Typescript-%234A5561?style=for-the-badge&logo=typescript&logoColor=white) ![Static Badge](https://img.shields.io/badge/Passport-%23434E5A?style=for-the-badge&logo=passport&logoSize=amg) + + + + + + + # e-commerce-mavericcks-bn diff --git a/package.json b/package.json index 140615de..c9a67a75 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "dev": "cross-env NODE_ENV=development nodemon src/server.ts", "start": "cross-env NODE_ENV=production node dist/src/server.js", "test": "cross-env NODE_ENV=test jest --coverage", + "coveralls": "cat ./coverage/lcov.info | node node_modules/.bin/coveralls", "lint": "eslint --ignore-path .eslintignore \"**/*.{js,ts}\"", "format": "prettier --ignore-path .gitignore --write \"**/*.+(js|ts|json)\"", "prepare": "husky install && npx husky add .husky/pre-commit \"npx lint-staged\"", @@ -69,6 +70,7 @@ "@typescript-eslint/eslint-plugin": "^7.7.0", "@typescript-eslint/parser": "^7.7.0", "babel-jest": "^29.7.0", + "coveralls": "^3.1.1", "cross-env": "^7.0.3", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.1.3", diff --git a/src/controllers/testController.ts b/src/controllers/testController.ts new file mode 100644 index 00000000..e7d7e4a5 --- /dev/null +++ b/src/controllers/testController.ts @@ -0,0 +1,3 @@ +export function addition(a: number, b: number) { + return a + b; +} diff --git a/src/test/index.test.ts b/src/test/index.test.ts index 79429b5b..1950c3aa 100644 --- a/src/test/index.test.ts +++ b/src/test/index.test.ts @@ -1,3 +1,21 @@ +import { addition } from '../controllers/testController'; + test('Adding 2 and 1 equals 3', () => { expect(2 + 1).toBe(3); }); +test('Addition function adds two numbers correctly', () => { + // Test case 1: Testing addition of positive numbers + expect(addition(2, 3)).toBe(5); // Expected result: 2 + 3 = 5 + + // Test case 2: Testing addition of negative numbers + expect(addition(-2, -3)).toBe(-5); // Expected result: -2 + (-3) = -5 + + // Test case 3: Testing addition of a positive and a negative number + expect(addition(5, -3)).toBe(2); // Expected result: 5 + (-3) = 2 + + // Test case 4: Testing addition of zero and a number + expect(addition(0, 7)).toBe(7); // Expected result: 0 + 7 = 7 + + // Test case 5: Testing addition of a number and zero + expect(addition(4, 0)).toBe(4); // Expected result: 4 + 0 = 4 +});