Skip to content

Commit

Permalink
Add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
andyjessop committed Oct 15, 2024
1 parent ea19e0b commit c70c4eb
Showing 1 changed file with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,41 @@ describe("ConfigController", () => {
});
});

it("should apply module root to parent if main is nested from base_dir", async () => {
const controller = new ConfigController();
const event = waitForConfigUpdate(controller);
await seed({
"some/base_dir/nested/index.js": dedent/* javascript */ `
export default {
fetch(request, env, ctx) {
return new Response("hello world")
}
}
`,
"wrangler.toml": dedent`
main = \"./some/base_dir/nested/index.js\"
base_dir = \"./some/base_dir\"`,
});

const config: StartDevWorkerInput = {};

await controller.set(config);

await expect(event).resolves.toMatchObject({
type: "configUpdate",
config: {
build: {
additionalModules: [],
define: {},
format: "modules",
moduleRoot: path.join(process.cwd(), "./some/base_dir"),
moduleRules: [],
},
directory: process.cwd(),
entrypoint: path.join(process.cwd(), "./some/base_dir/nested/index.js"),
},
});
});
it("should shallow merge patched config", async () => {
const controller = new ConfigController();
const event1 = waitForConfigUpdate(controller);
Expand Down

0 comments on commit c70c4eb

Please sign in to comment.