mirror of
https://github.com/miniflux/v2.git
synced 2025-08-06 17:41:00 +00:00
test(processor): add more unit tests for minifyContent
function
This commit is contained in:
parent
560be66147
commit
3de31a1a4d
2 changed files with 44 additions and 17 deletions
|
@ -1,17 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
|
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
package processor // import "miniflux.app/v2/internal/reader/processor"
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestMinifyEntryContent(t *testing.T) {
|
|
||||||
input := `<p> Some text with a <a href="http://example.org/"> link </a> </p>`
|
|
||||||
expected := `<p>Some text with a <a href="http://example.org/">link</a></p>`
|
|
||||||
result := minifyContent(input)
|
|
||||||
if expected != result {
|
|
||||||
t.Errorf(`Unexpected result, got %q`, result)
|
|
||||||
}
|
|
||||||
}
|
|
44
internal/reader/processor/utils_test.go
Normal file
44
internal/reader/processor/utils_test.go
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package processor // import "miniflux.app/v2/internal/reader/processor"
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestMinifyEntryContentWithWhitespace(t *testing.T) {
|
||||||
|
input := `<p> Some text with a <a href="http://example.org/"> link </a> </p>`
|
||||||
|
expected := `<p>Some text with a <a href="http://example.org/">link</a></p>`
|
||||||
|
result := minifyContent(input)
|
||||||
|
if expected != result {
|
||||||
|
t.Errorf(`Unexpected result, got %q`, result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMinifyContentWithDefaultAttributes(t *testing.T) {
|
||||||
|
input := `<script type="application/javascript">console.log("Hello, World!");</script>`
|
||||||
|
expected := `<script>console.log("Hello, World!");</script>`
|
||||||
|
result := minifyContent(input)
|
||||||
|
if expected != result {
|
||||||
|
t.Errorf(`Unexpected result, got %q`, result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMinifyContentWithComments(t *testing.T) {
|
||||||
|
input := `<p>Some text<!-- This is a comment --> with a <a href="http://example.org/">link</a>.</p>`
|
||||||
|
expected := `<p>Some text with a <a href="http://example.org/">link</a>.</p>`
|
||||||
|
result := minifyContent(input)
|
||||||
|
if expected != result {
|
||||||
|
t.Errorf(`Unexpected result, got %q`, result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMinifyContentWithSpecialComments(t *testing.T) {
|
||||||
|
input := `<p>Some text <!--[if IE 6]><p>IE6</p><![endif]--> with a <a href="http://example.org/">link</a>.</p>`
|
||||||
|
expected := `<p>Some text with a <a href="http://example.org/">link</a>.</p>`
|
||||||
|
result := minifyContent(input)
|
||||||
|
if expected != result {
|
||||||
|
t.Errorf(`Unexpected result, got %q`, result)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue