mirror of
https://github.com/miniflux/v2.git
synced 2025-07-02 16:38:37 +00:00
Move internal packages to an internal folder
For reference: https://go.dev/doc/go1.4#internalpackages
This commit is contained in:
parent
c234903255
commit
168a870c02
433 changed files with 1121 additions and 1123 deletions
64
internal/reader/sanitizer/truncate_test.go
Normal file
64
internal/reader/sanitizer/truncate_test.go
Normal file
|
@ -0,0 +1,64 @@
|
|||
// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package sanitizer
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestTruncateHTMWithTextLowerThanLimitL(t *testing.T) {
|
||||
input := `This is a <strong>bug 🐛</strong>.`
|
||||
expected := `This is a bug 🐛.`
|
||||
output := TruncateHTML(input, 50)
|
||||
|
||||
if expected != output {
|
||||
t.Errorf(`Wrong output: %q != %q`, expected, output)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTruncateHTMLWithTextAboveLimit(t *testing.T) {
|
||||
input := `This is <strong>HTML</strong>.`
|
||||
expected := `This…`
|
||||
output := TruncateHTML(input, 4)
|
||||
|
||||
if expected != output {
|
||||
t.Errorf(`Wrong output: %q != %q`, expected, output)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTruncateHTMLWithUnicodeTextAboveLimit(t *testing.T) {
|
||||
input := `This is a <strong>bike 🚲</strong>.`
|
||||
expected := `This…`
|
||||
output := TruncateHTML(input, 4)
|
||||
|
||||
if expected != output {
|
||||
t.Errorf(`Wrong output: %q != %q`, expected, output)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTruncateHTMLWithMultilineTextAboveLimit(t *testing.T) {
|
||||
input := `
|
||||
This is a <strong>bike
|
||||
🚲</strong>.
|
||||
|
||||
`
|
||||
expected := `This is a bike…`
|
||||
output := TruncateHTML(input, 15)
|
||||
|
||||
if expected != output {
|
||||
t.Errorf(`Wrong output: %q != %q`, expected, output)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTruncateHTMLWithMultilineTextLowerThanLimit(t *testing.T) {
|
||||
input := `
|
||||
This is a <strong>bike
|
||||
🚲</strong>.
|
||||
|
||||
`
|
||||
expected := `This is a bike 🚲.`
|
||||
output := TruncateHTML(input, 20)
|
||||
|
||||
if expected != output {
|
||||
t.Errorf(`Wrong output: %q != %q`, expected, output)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue