Last active
November 2, 2019 20:46
-
-
Save maxchehab/a840251715f7b691638d99ad0dc6150c to your computer and use it in GitHub Desktop.
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
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