summaryrefslogtreecommitdiffstats
path: root/modules/util/util_test.go
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2022-06-10 15:45:28 +0200
committerGitHub <noreply@github.com>2022-06-10 21:45:28 +0800
commit527e5bd1b29c1087d4b5375beac519d0b74294eb (patch)
treee5f96a202f7e17b3d117032260cb96848c4b11b1 /modules/util/util_test.go
parent4d8e9f3b849223ede0f11cf7a0a9296d0bce048c (diff)
downloadgitea-527e5bd1b29c1087d4b5375beac519d0b74294eb.tar.gz
gitea-527e5bd1b29c1087d4b5375beac519d0b74294eb.zip
Fix copy/paste of empty lines (#19798)
* Fix copy/paste of empty newlines again Fixes: https://github.com/go-gitea/gitea/issues/19331 Regressed by: https://github.com/go-gitea/gitea/pull/18270 Needed to do another newline addition to the Chroma output HTML to get copy/paste work again. The previous replacement conditions are probably obsolete, but as I'm not 100% sure, I opted to keep them. Specifically, the Chroma HTML change mentioned in https://github.com/go-gitea/gitea/pull/18270#issuecomment-1013350246 broke our previous newline replacement for such empty lines. Also included are a few changes to make the test more pleasant to work with. * run go mod tidy * add util.Dedent * copy in the code Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'modules/util/util_test.go')
-rw-r--r--modules/util/util_test.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/modules/util/util_test.go b/modules/util/util_test.go
index ca5bd87eae..91b0ef9455 100644
--- a/modules/util/util_test.go
+++ b/modules/util/util_test.go
@@ -225,3 +225,10 @@ func TestToTitleCase(t *testing.T) {
assert.Equal(t, ToTitleCase(`foo bar baz`), `Foo Bar Baz`)
assert.Equal(t, ToTitleCase(`FOO BAR BAZ`), `Foo Bar Baz`)
}
+
+func TestDedent(t *testing.T) {
+ assert.Equal(t, Dedent(`
+ foo
+ bar
+ `), "foo\n\tbar")
+}