(t *testing.T)
| 49 | } |
| 50 | |
| 51 | func 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 | } |
nothing calls this directly
no test coverage detected