// Copyright (c) 2022 Tulir Asokan // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. package format_test import ( "strings" "testing" "github.com/stretchr/testify/assert" "maunium.net/go/mautrix/format" ) var spoilerTests = map[string]string{ "test ||bar||": "test bar", "test ||reason|**bar**||": `test bar`, "test ||reason|[bar](https://example.com)||": `test bar`, "test [||reason|foo||](https://example.com)": `test foo`, "test [||foo||](https://example.com)": `test foo`, "test [||*foo*||](https://example.com)": `test foo`, // FIXME wrapping spoilers in italic/bold/strikethrough doesn't work for some reason //"test **[||foo||](https://example.com)**": `test foo`, //"test **||foo||**": `test foo`, "* ||foo||": ``, "> ||foo||": "

foo

", } func TestRenderMarkdown_Spoiler(t *testing.T) { for markdown, html := range spoilerTests { rendered := format.RenderMarkdown(markdown, true, false) // FIXME the HTML parser doesn't do spoilers yet //assert.Equal(t, plaintext, rendered.Body) assert.Equal(t, html, strings.ReplaceAll(rendered.FormattedBody, "\n", "")) } }