Skip to content

Instantly share code, notes, and snippets.

@qunabu
Created November 26, 2020 09:35
Show Gist options
  • Save qunabu/fbd38d6046da2cc2d6548f7a599fbcdb to your computer and use it in GitHub Desktop.
Save qunabu/fbd38d6046da2cc2d6548f7a599fbcdb to your computer and use it in GitHub Desktop.
Mockowanie API
const request = require("supertest");
jest.mock("node-fetch", () => require("fetch-mock-jest").sandbox());
const fetchMock = require("node-fetch");
it("validates general PDF investment for user", async (done) => {
fetchMock.mock("https://weryfikacjapodpisu.pl/api/verify", {
body: fs.readFileSync("./tests/poa/weryf_correct.json", "utf8"),
});
await request(app.server)
.post("/poas/validate")
.set("Authorization", "Bearer " + jwt)
.attach("attachment", "./tests/poa/__test-general.pdf.xml")
.expect("Content-Type", /json/)
.expect(200);
done();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment