gradio/js/markdown/Markdown.test.ts
pngwn 2b6cbf2590
Fix published package exports (#9163)
* rename

* save patch

* fix everything

* format

* rm file

* fix stuff

* tweaks

* tweaks

* tweaks

* tweaks

* tweaks

* asd

* asd

* asd

* asd

* asd

* asd

* asd

* fix

* Fix scripts/run_lite.sh and scripts/build_lite.sh (#9170)

* fixes

* fixes

* asd

* asd

* asd

* review comments

* fiux types

* fiux types

* make fileexpolorer public

* format

* lint

* lint

---------

Co-authored-by: Yuichiro Tachibana (Tsuchiya) <t.yic.yt@gmail.com>
2024-08-22 16:38:45 +00:00

53 lines
1.3 KiB
TypeScript

import { test, describe, assert, afterEach } from "vitest";
import { cleanup, render } from "@self/tootils";
import Markdown from "./Index.svelte";
import type { LoadingStatus } from "@gradio/statustracker";
const loading_status: LoadingStatus = {
eta: 0,
queue_position: 1,
queue_size: 1,
status: "complete" as LoadingStatus["status"],
scroll_to_output: false,
visible: true,
fn_index: 0,
show_progress: "full"
};
describe("Markdown", () => {
afterEach(() => cleanup());
test("renders valid URL", async () => {
const { getByText } = await render(Markdown, {
show_label: true,
max_lines: 1,
loading_status,
lines: 1,
value: "Visit [Gradio](https://www.gradio.app/) for more information.",
label: "Markdown",
interactive: false
});
const link: HTMLAnchorElement = getByText("Gradio") as HTMLAnchorElement;
assert.equal(link.href, "https://www.gradio.app/");
});
test("renders invalid URL", async () => {
const { getByText } = await render(Markdown, {
show_label: true,
max_lines: 1,
loading_status,
lines: 1,
value: "Visit [Invalid URL](https://) for more information.",
label: "Markdown",
interactive: false
});
const link: HTMLAnchorElement = getByText(
"Invalid URL"
) as HTMLAnchorElement;
assert.equal(link.href, "https://");
});
});