2020-08-18 15:47:53 +08:00
|
|
|
import {
|
|
|
|
resolveAppFunction,
|
|
|
|
Resolver,
|
|
|
|
} from "../src/helpers/resolve-app-function";
|
2017-10-14 20:25:02 +08:00
|
|
|
|
2020-08-18 15:47:53 +08:00
|
|
|
const stubAppFnPath = require.resolve("./fixtures/plugin/stub-plugin");
|
|
|
|
const basedir = process.cwd();
|
2017-10-14 20:25:02 +08:00
|
|
|
|
2020-08-18 15:47:53 +08:00
|
|
|
describe("resolver", () => {
|
|
|
|
let stubResolver: Resolver;
|
2017-10-14 20:25:02 +08:00
|
|
|
|
2017-10-14 21:02:34 +08:00
|
|
|
beforeEach(() => {
|
2020-08-18 15:47:53 +08:00
|
|
|
stubResolver = jest.fn().mockReturnValue(stubAppFnPath);
|
|
|
|
});
|
2017-10-14 20:25:02 +08:00
|
|
|
|
2020-08-18 15:47:53 +08:00
|
|
|
it("loads the module at the resolved path", () => {
|
|
|
|
const module = resolveAppFunction("foo", { resolver: stubResolver });
|
|
|
|
expect(module).toBe(require(stubAppFnPath));
|
|
|
|
expect(stubResolver).toHaveBeenCalledWith("foo", { basedir });
|
|
|
|
});
|
|
|
|
});
|