MCPcopy Index your code
hub / github.com/coder/coder / TestHTML

Function TestHTML

coderd/render/markdown_test.go:51–89  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

49}
50
51func TestHTML(t *testing.T) {
52 t.Parallel()
53
54 tests := []struct {
55 name string
56 input string
57 expected string
58 }{
59 {
60 name: "Simple",
61 input: `**Coder** is in *early access* mode. To ~~register~~ request access, fill out [this form](https://internal.example.com). ***Thank you!***`,
62 expected: `<p><strong>Coder</strong> is in <em>early access</em> mode. To <del>register</del> request access, fill out <a href="https://internal.example.com">this form</a>. <strong><em>Thank you!</em></strong></p>`,
63 },
64 {
65 name: "Tricky",
66 input: `**Cod*er** is in *early a**ccess** <img src="foobar">mode`,
67 expected: `<p><strong>Cod*er</strong> is in *early a<strong>ccess</strong> mode</p>`,
68 },
69 {
70 name: "XSS",
71 input: `<p onclick="alert(\"omghax\")">Click here to get access!</p>?`,
72 expected: `<p>Click here to get access!?</p>`,
73 },
74 {
75 name: "No Markdown tags",
76 input: "This is a simple description, so nothing changes.",
77 expected: "<p>This is a simple description, so nothing changes.</p>",
78 },
79 }
80
81 for _, tt := range tests {
82 t.Run(tt.name, func(t *testing.T) {
83 t.Parallel()
84
85 rendered := render.HTMLFromMarkdown(tt.input)
86 require.Equal(t, tt.expected, rendered)
87 })
88 }
89}

Callers

nothing calls this directly

Calls 3

HTMLFromMarkdownFunction · 0.92
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected