test("Dynamic path with param and nested index", () => { return get("/dynamicpaths/param1/nested", { json: true }).then(data => { expect(data.nestedIndex).toBe(true); }); });
test("MDX HMR (add a new handler and modify it)", async () => { expect.assertions(2); await writeFile("mdx.mdx", CODES["mdx"]); return get("/hmr/mdx").then(async data => { expect(data).toContain("Hello MDX"); await writeFile("mdx.mdx", CODES["mdx"].replace("Hello", "Hey")); return get("/hmr/mdx").then(data => { expect(data).toContain("Hey MDX"); }); }); });
test("HTML With SCSS Style", () => { //expect.assertions(1); return get("/html/withScriptAndStyle").then(data => { const $ = cheerio.load(data); expect( $('[rel="stylesheet"]') .attr("href") .endsWith(".css") ).toBe(true); }); });
test("React With Default Meta Charset", () => { //expect.assertions(1); return get("/react/withhelmet").then(data => { const $ = cheerio.load(data); expect($("head [charset]").attr("charset")).toBe("utf-8"); }); });
test("Dynamic path with param and nested param", () => { return get("/dynamicpaths/param1/nested/nestedParam1", { json: true }).then( data => { expect( data.param === "param1" && data.nestedParam === "nestedParam1" ).toBe(true); } ); });
test("Fixed/Pinned path", () => { return get("/proxy/fixed", { json: true }).then(data => { expect(data.path).toBe("/fixedRoute"); }); });
test("React With Hooks", () => { //expect.assertions(1); return get("/react/withHook").then(data => { const $ = cheerio.load(data); expect($("p").text()).toBe("You clicked 0 times"); }); });
test("path with space", () => { // expect.assertions(1); return get("/api/with space", { json: true }).then(data => { expect(data["withspace"]).toBe(true); }); });
test("Svelte HMR (add a new handler and modify it)", async () => { expect.assertions(2); await writeFile("svelte.svelte", CODES["svelte"]); return get("/hmr/svelte").then(async data => { expect(data).toContain("Hello Svelte"); await writeFile("svelte.svelte", CODES["svelte"].replace("Hello", "Hey")); return get("/hmr/svelte").then(data => { expect(data).toContain("Hey Svelte"); }); }); });
test("path with dot", () => { // expect.assertions(1); return get("/api/with.dot", { json: true }).then(data => { expect(data["withdot"]).toBe(true); }); });
// with query param test("Query Param", () => { return get("/python/queryparam?name=asad", {}).then(data => { expect(data).toBe("Hello, asad"); }); });
test("CWD is correctly set", () => { return get("/python/cwd").then(data => { expect(data).toBe("some text"); }); });
test("HTML HMR (add a new handler and modify it)", async () => { expect.assertions(2); await writeFile("html.html", CODES["html"]); return get("/hmr/html").then(async data => { expect(data).toContain("Hello HTML"); await writeFile("html.html", CODES["html"].replace("Hello", "Hey")); return get("/hmr/html").then(data => { expect(data).toContain("Hey HTML"); }); }); });
test("Vue HMR (add a new handler and modify it)", async () => { expect.assertions(2); await writeFile("vue.vue", CODES["vue"]); return get("/hmr/vue").then(async data => { expect(data).toContain("Hello Vue"); await writeFile("vue.vue", CODES["vue"].replace("Hello", "Hey")); return get("/hmr/vue").then(data => { expect(data).toContain("Hey Vue"); }); }); });
test("HTML With Script", () => { //expect.assertions(1); return get("/html/withScriptAndStyle").then(data => { const $ = cheerio.load(data); expect( $("script") .attr("src") .endsWith(".js") ).toBe(true); }); });