/* 
* Say that I want to test a component with an imported function that has different behaviours.
*
* e.g. 
* import { authenticate } from "~/some/module"
* authenticate: (...) => boolean
*
*/

jest.mock("~/some/module");
const AuthenticationService = require("~/some/module");

describe("when authentication is invalid", () => {
  beforeEach(() => {
    AuthenticationService.authenticate = jest.fn().mockResolvedValue(false);
  });

  test("the flow should fail", async () => {
    const result = await someHOC("username", "wrong-password");
    expect(result).toEqual(401);
  });
});

describe("when authentication is valid", () => {
  beforeEach(() => {
    AuthenticationService.authenticate = jest.fn().mockResolvedValue(true);
  });

  test("the flow should pass", () => {
    const result = someHOC("username", "correct-password");
    expect(result).toEqual(200);
  });
});