-
-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added first unittests for api endpoints
- Loading branch information
Showing
4 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
const supertest = require("supertest"); | ||
const request = supertest("http://localhost:1870"); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const supertest = require("supertest"); | ||
const request = supertest("http://localhost:3001"); | ||
|
||
describe("/api/register", () => { | ||
describe("POST", () => { | ||
test("without body", async () => { | ||
const response = await request.post("/api/auth/register").send({}); | ||
expect(response.statusCode).toBe(400); | ||
}); | ||
test("with body", async () => { | ||
const response = await request.post("/api/auth/register").send({ | ||
fingerprint: "805826570869932034.wR8vi8lGlFBJerErO9LG5NViJFw", | ||
email: "qo8etzvaf@gmail.com", | ||
username: "qp39gr98", | ||
password: "wtp9gep9gw", | ||
invite: null, | ||
consent: true, | ||
date_of_birth: "2000-04-04", | ||
gift_code_sku_id: null, | ||
captcha_key: null | ||
}); | ||
expect(response.statusCode).toBe(200); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const supertest = require("supertest"); | ||
const request = supertest("http://localhost:3001"); | ||
|
||
describe("/ping", () => { | ||
describe("GET", () => { | ||
test("should return 200 and pong", async () => { | ||
let response = await request.get("/api/ping"); | ||
expect(response.text).toBe("pong"); | ||
expect(response.statusCode).toBe(200); | ||
}); | ||
}); | ||
}); |