const geo = require("../geo");

describe("geo", () => {
  it("returns the correct country name for an IP address", async () => {
    const req: any = {
      headers: { "x-forwarded-for": "8.8.8.8"},
      connection: { remoteAddress: "8.8.8.8"}
    };

    const res: any = {
      status: jest.fn().mockReturnThis(),
      json: jest.fn()
    };

    await geo(req, res);
    expect(res.status).toHaveBeenCalledWith(200);
    expect(res.json).toHaveBeenCalledWith(
      expect.objectContaining({
        lang: "en",
        info: { ip: "8.8.8.8" }
      })
    );
  });
});
