import { test, expect } from "vitest"; import { createTemplateComponentFixture, renderTemplate, ws, } from "@webstudio-is/template"; import { __testing__ } from "./plugin-markdown"; const Image = createTemplateComponentFixture("Image"); const { parse } = __testing__; test("paragraph", () => { expect(parse("xyz")).toEqual( renderTemplate(xyz) ); }); test("h1", () => { expect(parse("# heading")).toEqual( renderTemplate(heading) ); }); test("h6", () => { expect(parse("###### heading")).toEqual( renderTemplate(heading) ); }); test("bold 1", () => { expect(parse("__bold__")).toEqual( renderTemplate( bold ) ); }); test("bold 2", () => { expect(parse("**bold**")).toEqual( renderTemplate( bold ) ); }); test("italic 1", () => { expect(parse("_italic_")).toEqual( renderTemplate( italic ) ); }); test("italic 2", () => { expect(parse("*italic*")).toEqual( renderTemplate( italic ) ); }); test("link", () => { expect(parse('[link](/uri "Title")')).toEqual( renderTemplate( link ) ); }); test("autolink", () => { expect(parse("https://github.com")).toEqual( renderTemplate( https://github.com ) ); }); test("image", () => { expect(parse('![foo](/url "title")')).toEqual( renderTemplate( foo ) ); }); test("hard line break", () => { expect( parse(`foo baz`) ).toEqual( renderTemplate( foo baz ) ); }); test("soft line break", () => { expect( parse(`foo baz`) ).toEqual(renderTemplate(foo baz)); }); test("blockquote", () => { expect(parse("> bar")).toEqual( renderTemplate( bar ) ); }); test("inline code", () => { expect(parse("`foo` and `bar`")).toEqual( renderTemplate( foo and bar ) ); }); test("code", () => { expect(parse("```js meta\nfoo\nbar\n```")).toEqual( renderTemplate( {"foo\nbar\n"} ) ); }); test("list unordered", () => { expect(parse("- one")).toEqual( renderTemplate( one ) ); }); test("list ordered", () => { expect(parse("3. one")).toEqual( renderTemplate( one ) ); }); test("thematic break | separator", () => { expect(parse("---")).toEqual(renderTemplate()); }); test("strikethrough", () => { expect(parse("~One~\n\n~~two~~")).toEqual( renderTemplate( <> One two ) ); }); test("preserve spaces between strong and em", () => { expect(parse("**One** *two* text")).toEqual( renderTemplate( <> {"One "} two {" text"} ) ); }); test("table", () => { expect( parse(` | Header 1 | Header 2 | |------------|------------| | Cell 1.1 | Cell 1.2 | | Cell 2.1 | Cell 2.2 | `) ).toEqual( renderTemplate( Header 1 Header 2 Cell 1.1 Cell 1.2 Cell 2.1 Cell 2.2 ) ); });