Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Endpoint users #13

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
cb71387
users test done
mammuttaqin Sep 17, 2021
44635bf
update verification tests
mammuttaqin Sep 17, 2021
f767798
get, post loan
mammuttaqin Sep 17, 2021
c66626c
Merge pull request #1 from mammuttaqin/user-test
mammuttaqin Sep 17, 2021
014388b
Merge branch 'development' into loan-test
mammuttaqin Sep 17, 2021
412d887
Merge pull request #2 from mammuttaqin/loan-test
mammuttaqin Sep 17, 2021
7d78e87
loan test
mammuttaqin Sep 17, 2021
9fa9f09
Merge branch 'loan-test' of https://github.com/mammuttaqin/pinjamanku…
mammuttaqin Sep 17, 2021
560a627
user: login, register
mammuttaqin Sep 18, 2021
1c812d5
Merge pull request #3 from mammuttaqin/db-creation
mammuttaqin Sep 18, 2021
68e8f2c
add external id
mammuttaqin Sep 18, 2021
886a8b2
add xendit
mammuttaqin Sep 18, 2021
d3dbe98
deploy heroku
mammuttaqin Sep 18, 2021
be8e4f0
Merge pull request #4 from mammuttaqin/db-with-xendit
mammuttaqin Sep 18, 2021
e7c5d07
nodemailerTest
Sep 19, 2021
35fb5ec
users controller
mammuttaqin Sep 19, 2021
41fa237
nodemailer+dailyco
Sep 19, 2021
e2860e3
merge dev with nodemailer test
mammuttaqin Sep 19, 2021
3c6901a
initialization
mammuttaqin Sep 19, 2021
78fdbd4
merge create-schedule and nodeMailerTest
mammuttaqin Sep 19, 2021
2cafeaa
merge create-schedule and nodeMailerTest 2
mammuttaqin Sep 19, 2021
33af1a0
import loan controllers
mammuttaqin Sep 19, 2021
532fd8b
to use
mammuttaqin Sep 19, 2021
4abff5f
add field lender and borrower
mammuttaqin Sep 20, 2021
524456f
refactor user to lender, borrower, and staff
mammuttaqin Sep 20, 2021
581a181
Merge pull request #12 from mammuttaqin/endpoint-users
mammuttaqin Sep 20, 2021
9ceef0a
CRUD users
mammuttaqin Sep 20, 2021
1d63ce4
updating user Controllers
mammuttaqin Sep 20, 2021
17eb5f8
Merge pull request #15 from mammuttaqin/apply-middlewares
mammuttaqin Sep 20, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion server/.env
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
PORT=3000
SECRET=ToMakeNewTokenForNewUser
SECRET_KEY_XENDIT=xnd_development_S1YRENVA6FA1ELZerCvKR3NaBY1J7Jm2JLLhawkAzF7R5gTg4SvcAZfaXPIKA0n
API_KEY_DAILY_CO=8b8b5a44c122c56ddf936637d5cc1b0eecec8afe030137b52b176fbec1ed0c08
DOMAIN_EMAIL_ADMIN=protonmail.com
3 changes: 2 additions & 1 deletion server/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
node_modules
.env
1 change: 1 addition & 0 deletions server/Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: npm start
120 changes: 120 additions & 0 deletions server/_tests_/loans.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
const app = require("../app");
const request = require("supertest");

const newLoan = {
borrowerId,
lenderId,
amount: 3000000,
tenor: 60,
};

describe("GET /loans [SUCCESS CASE]", () => {
test("Should return array of object of loans", (done) => {
request(app)
.get("/loans")
.then(({ status, body }) => {
expect(status).toBe(200);
expect(body).not.toHaveLength(0);
expect(body[0]).toHaveProperty("id");
expect(body[0]).toHaveProperty("firstName");
expect(body[0]).toHaveProperty("lastName");
expect(body[0]).toHaveProperty("amount");
expect(body[0]).toHaveProperty("tenor");
expect(body[0]).toHaveProperty("status");
done();
})
.catch((err) => done(err));
});
});

describe("POST /loans [SUCCESS CASE]", () => {
test("Should return an object about details Loan", (done) => {
request(app)
.post("/loans")
.set("access_token", access_token)
.send(newLoan)
.then(({ status, body }) => {
expect(status).toBe(201);
expect(body).toHaveProperty("id", expect.any(Number));
expect(body).toHaveProperty("borrowerId");
expect(body).toHaveProperty("lenderId");
expect(body).toHaveProperty("amount");
expect(body).toHaveProperty("tenor");
expect(body).toHaveProperty("status");
done();
})
.catch((err) => done(err));
});
});

describe("POST /loans [FAIL CASE]", () => {
test("Should return an object about details Loan", (done) => {
request(app)
.post("/loans")
.set("access_token", access_token_fail)
.send(newLoan)
.then(({ status, body }) => {
expect(status).toBe(400);
expect(body).toHaveProperty("message", "invalid user token");
done();
})
.catch((err) => done(err));
});
});

describe("POST /loans [FAIL CASE]", () => {
test("Should return an object with property message", (done) => {
const failLoan = {
...newLoan,
amount: null,
};
request(app)
.post("/loans")
.set("access_token", access_token)
.send(failLoan)
.then(({ status, body }) => {
expect(status).toBe(400);
expect(body).toHaveProperty("message", "amount cannot be null");
done();
})
.catch((err) => done(err));
});
});

describe("POST /loans [FAIL CASE]", () => {
test("Should return an object with property message", (done) => {
const failLoan = {
...newLoan,
tenor: null,
};
request(app)
.post("/loans")
.set("access_token", access_token)
.send(failLoan)
.then(({ status, body }) => {
expect(status).toBe(400);
expect(body).toHaveProperty("message", "tenor cannot be null");
done();
})
.catch((err) => done(err));
});
});

describe("PATCH /loans [SUCCESS CASE]", () => {
test("Should return an object about details Loan", (done) => {
request(app)
.post("/loans")
.set("access_token", access_token)
.send(newLoan)
.then(({ status, body }) => {
expect(status).toBe(201);
expect(body).toHaveProperty("id", expect.any(Number));
expect(body).toHaveProperty("borrowerId");
expect(body).toHaveProperty("lenderId");
expect(body).toHaveProperty("amount");
expect(body).toHaveProperty("tenor");
done();
})
.catch((err) => done(err));
});
});
Loading