Skip to content

Commit

Permalink
Merge pull request #9 from PRATHAM1ST/master
Browse files Browse the repository at this point in the history
Tests Are Fixed
  • Loading branch information
PRATHAM1ST authored Sep 16, 2023
2 parents 50ffa22 + 4bcb1f7 commit 024a9ad
Show file tree
Hide file tree
Showing 11 changed files with 199 additions and 7,569 deletions.
33 changes: 15 additions & 18 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Node.js Test

name: Unit Tests
on:
push:
branches: [ "master" ]
branches: [ master ]
pull_request:
branches: [ "master" ]
branches: [ master ]

#
jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

#
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm test
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
# This step runs `npm ci` to install any dependencies listed in your `package.json` file.
- name: npm install
run: npm install
- name: npm test
run: npm test
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ node_modules
.env.local
.env.*

npm-debug.log*
npm-debug.log*

package-lock.json
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ This route returns a JSON array of objects containing details of GitHub communit

- `name`: Name
- `username`: GitHub username
- `profile_url`: Profile picture URL
- `profile_pic_url`: Profile picture URL
- `followers`: Number of followers
- `following`: Number of people they follow
- `repositories`: Number of repositories
- `bio`: Bio
- `github_link`: GitHub profile URL

**Example Response:**
```json
Expand Down Expand Up @@ -85,4 +86,9 @@ We maintain code quality by using ESLint with the Airbnb style guide. You can ch
- To check for issues: `npm run lint`
- To automatically fix fixable issues: `npm run lint:fix`

## Code testing

We use Jest for testing. You can run the tests with `npm test`.


That's it! You are now ready to use our API to access community member data or explore other available routes. If you have any questions or encounter issues, feel free to reach out to us. Happy coding!
6 changes: 4 additions & 2 deletions __tests__/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import request from "supertest";
import app from "../index";
import app from "../app";

describe("GET /", () => {
it("should return a 200 response", async () => {
Expand Down Expand Up @@ -35,9 +35,11 @@ describe("GET /members", () => {
const member = res.body.data[0];
expect(member).toHaveProperty("name");
expect(member).toHaveProperty("username");
expect(member).toHaveProperty("profile_url");
expect(member).toHaveProperty("profile_pic_url");
expect(member).toHaveProperty("followers");
expect(member).toHaveProperty("following");
expect(member).toHaveProperty("repositories");
expect(member).toHaveProperty("bio");
expect(member).toHaveProperty("github_link");
});
});
4 changes: 0 additions & 4 deletions index.ts → app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,4 @@ app.get("/", (req: Request, res: Response) => {

app.use("/members", membersRoute);

app.listen(3000, () => {
console.log("Example app listening on port 3000!");
});

export default app;
10 changes: 5 additions & 5 deletions controllers/members.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ const getUserInfo = async (html: string) => {
if (!repositories) console.log("Repositories not found");

return {
profile_pic_url: photoSrc.href,
profile_pic_url: photoSrc?.href,
followers: followersAndFollowing[0]
? followersAndFollowing[0].innerText
: "0",
following: followersAndFollowing[1]
? followersAndFollowing[1].innerText
: "0",
repositories: repositories.title,
bio: bio.innerText ?? "",
repositories: repositories?.title,
bio: bio?.innerText ?? "",
};
};

Expand Down Expand Up @@ -99,7 +99,7 @@ export async function PATCH(req: Request, res: Response) {
} catch (err) {
return res.status(500).json({
status: false,
message: err.message,
message: err,
});
}
}
Expand All @@ -114,7 +114,7 @@ export async function GET(req: Request, res: Response) {
} catch (err) {
return res.status(500).json({
status: false,
message: err.message,
message: err,
});
}
}
Expand Down
Loading

0 comments on commit 024a9ad

Please sign in to comment.