import { render } from "@testing-library/react"; import "@testing-library/jest-dom"; import { VuiSummary } from "./Summary"; import { VuiSummaryCitation } from "./SummaryCitation"; describe("VuiSummary", () => { describe("renders markdown", () => { test("without citations", () => { const summary = ` # Here's a heading 1 ## Here's a heading 2 ### Here's a heading 3 #### Here's a heading 4 With some **bold** and _emphasized_ test. Here is a [link](https://www.vectara.com). * An * Unordered * List 1. An 1. Ordered 1. List | Syntax | Description | | ----------- | ----------- | | Header | Title | | Paragraph | Text | `; const { asFragment } = render(); expect(asFragment()).toMatchInlineSnapshot(`

Here's a heading 1

Here's a heading 2

Here's a heading 3

Here's a heading 4

With some bold and emphasized test. Here is a link .

  • An
  • Unordered
  • List
  1. An
  2. Ordered
  3. List
Syntax Description
Header Title
Paragraph Text
`); }); test("with citations", () => { const summary = ` # [1] Here's a heading 1 ## [1] Here's a heading 2 ### [1] Here's a heading 3 #### [1] Here's a heading 4 With some **bold** [2][3] and _emphasized_ [2][3] test. Here is a [link](https://www.vectara.com) [2][3]. * An [2][3] * Unordered [2][3] * List [2][3] 1. An [2][3] 1. Ordered [2][3] 1. List [2][3] | Syntax | Description | | ----------- | ----------- | | Header | Title [2][3] | | Paragraph | Text | `; const { asFragment } = render(); expect(asFragment()).toMatchInlineSnapshot(`

Here's a heading 1

Here's a heading 2

Here's a heading 3

Here's a heading 4

With some bold and emphasized test. Here is a link .

  • An
  • Unordered
  • List
  1. An
  2. Ordered
  3. List
Syntax Description
Header Title
Paragraph Text
`); }); }); describe("renders citations with correct spacing", () => { test("with single citations", () => { const summary = "[1] Beginning of summary. [2][3] Multiple at beginning of sentence, and before comma [4], single at middle [5] of sentence. At end of sentence [6]."; const { asFragment } = render(); expect(asFragment()).toMatchInlineSnapshot(`
Beginning of summary. Multiple at beginning of sentence, and before comma , single at middle of sentence. At end of sentence .
`); }); test("at the end of the summary", () => { const summary = "End of summary. [1]"; const { asFragment } = render(); expect(asFragment()).toMatchInlineSnapshot(`

End of summary.

`); }); test("with multiple comma-delimited citations", () => { const summary = "Two citations [1, 2] and seven citations [1, 2, 3, 4, 5, 6, 7]."; const { asFragment } = render(); expect(asFragment()).toMatchInlineSnapshot(`

Two citations and seven citations .

`); }); }); });