-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
backend: add test to handle payments with opencollective
- Loading branch information
Showing
2 changed files
with
55 additions
and
0 deletions.
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,46 @@ | ||
import { expect } from "chai"; | ||
import request from "supertest"; | ||
import dotenv from "dotenv"; | ||
|
||
dotenv.config(); | ||
const apiHost = process.env.API_HOST; | ||
const endpoint = "pay"; | ||
|
||
describe(`${endpoint}`, function () { | ||
describe("POST", function () { | ||
it("fails to make a payment with invalid email address", async function () { | ||
return request(apiHost) | ||
.post(`${endpoint}`) | ||
.set("Accept", "application/json") | ||
.send({ | ||
email: "wrong email", | ||
tier: "new jobsika tier", | ||
job_offer_id: "1", | ||
}) | ||
.expect(400) | ||
.expect("Content-Type", "application/json; charset=utf-8") | ||
.then((res) => { | ||
expect(JSON.stringify(res.body)).contain("email field is invalid"); | ||
}); | ||
}); | ||
|
||
it("proceed with a payment", async function () { | ||
return request(apiHost) | ||
.post(`${endpoint}`) | ||
.set("Accept", "application/json") | ||
.send({ | ||
email: "[email protected]", | ||
tier: "new jobsika tier", | ||
job_offer_id: "1", | ||
}) | ||
.expect(200) | ||
.expect("Content-Type", "application/json; charset=utf-8") | ||
.then((res) => { | ||
expect(JSON.stringify(res.body)).contain( | ||
"opencollective.com" | ||
); | ||
}); | ||
}); | ||
|
||
}); | ||
}); |
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