Skip to content

Instantly share code, notes, and snippets.

@maxchehab
Last active November 2, 2019 20:46
Show Gist options
  • Save maxchehab/a840251715f7b691638d99ad0dc6150c to your computer and use it in GitHub Desktop.
Save maxchehab/a840251715f7b691638d99ad0dc6150c to your computer and use it in GitHub Desktop.
import { apiResolver } from "next-server/dist/server/api-utils";
import axios from "axios";
import http from "http";
import listen from "test-listen";
import token from "./token";
const requestHandler = (req: any, res: any) =>
apiResolver(req, res, undefined, token);
describe("token", () => {
describe("with invalid code", () => {
it("returns 400, Invalid Code", async () => {
const server = http.createServer(requestHandler);
const url = await listen(server);
const { status, data } = await axios.get(url, {
validateStatus: () => true
});
expect(status).toBe(400);
expect(data).toBe({
message: "Invalid code."
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment