through.obj((file, enc, next) => { if (file.isNull() || file.isDirectory()) { next(null, file); return; } if (!some(file.extname, file.history[0])) { next(null, file); return; } file.$ = cheerio.load(file.contents.toString(), options); next(null, file); })
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(".MDX File (With Syntax Highlight)", () => { //expect.assertions(1); return get("/mdx/syntaxhighlight").then(data => { const $ = cheerio.load(data); expect($("pre").attr("class")).toBe("prism-code language-js"); }); });
test(".MD File (Simple)", () => { //expect.assertions(1); return get("/mdx/heading").then(data => { const $ = cheerio.load(data); expect( $("body h1") .text() .trim() ).toBe("Heading"); }); });
test("React With CSS import from node_modules", () => { //expect.assertions(1); return get("/react/withnpmstyle").then(data => { const $ = cheerio.load(data); expect($("button").text()).toBe("Button"); }); });
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); }); });
test("React With Helmet", () => { //expect.assertions(1); return get("/react/withhelmet").then(data => { const $ = cheerio.load(data); expect( $("head title") .text() .trim() ).toBe("Page Title"); }); });
test("MDX With Helmet", () => { //expect.assertions(1); return get("/mdx/withhelmet").then(data => { const $ = cheerio.load(data); expect( $("head title") .text() .trim() ).toBe("Page Title"); }); });
test("React With Custom Meta Charset", () => { //expect.assertions(1); return get("/react/withcustomcharset").then(data => { const $ = cheerio.load(data); expect($("head [charset]").attr("charset")).toBe("ISO-8859-1"); }); });
test("React With Imports", () => { //expect.assertions(1); return get("/vue/withimports").then(data => { const $ = cheerio.load(data); expect( $("body") .text() .trim() ).toBe("2, 4, 6"); }); });
test("Vue With asyncData", () => { //expect.assertions(1); return get("/vue/withAsyncData/?id=abc").then(data => { const $ = cheerio.load(data); expect( $("body") .text() .trim() ).toBe("abc"); }); });
test("HTML (Simple)", () => { //expect.assertions(1); return get("/html").then(data => { const $ = cheerio.load(data); expect( $("body h1") .text() .trim() ).toBe("Title"); }); });
test(".MDX File (With .JSX Import)", () => { //expect.assertions(1); return get("/mdx/withimportjsx").then(data => { const $ = cheerio.load(data); expect( $("body") .text() .trim() ).toBe("react-stateless"); }); });
test("React With Class Properties", () => { //expect.assertions(1); return get("/react/withClassProperties").then(data => { const $ = cheerio.load(data); expect($("button").text()).toBe("Click Me!"); }); });
test("Svelte With Preloading", () => { //expect.assertions(1); return get("/svelte/withpreloading").then(data => { const $ = cheerio.load(data); expect( $("body p") .text() .trim() ).toBe("2,4,6"); }); });