utils_test.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
  2. // SPDX-License-Identifier: Apache-2.0
  3. package processor // import "miniflux.app/v2/internal/reader/processor"
  4. import (
  5. "testing"
  6. )
  7. func TestMinifyEntryContentWithWhitespace(t *testing.T) {
  8. input := `<p> Some text with a <a href="http://example.org/"> link </a> </p>`
  9. expected := `<p>Some text with a <a href="http://example.org/">link</a></p>`
  10. result := minifyContent(input)
  11. if expected != result {
  12. t.Errorf(`Unexpected result, got %q`, result)
  13. }
  14. }
  15. func TestMinifyContentWithDefaultAttributes(t *testing.T) {
  16. input := `<script type="application/javascript">console.log("Hello, World!");</script>`
  17. expected := `<script>console.log("Hello, World!");</script>`
  18. result := minifyContent(input)
  19. if expected != result {
  20. t.Errorf(`Unexpected result, got %q`, result)
  21. }
  22. }
  23. func TestMinifyContentWithComments(t *testing.T) {
  24. input := `<p>Some text<!-- This is a comment --> with a <a href="http://example.org/">link</a>.</p>`
  25. expected := `<p>Some text with a <a href="http://example.org/">link</a>.</p>`
  26. result := minifyContent(input)
  27. if expected != result {
  28. t.Errorf(`Unexpected result, got %q`, result)
  29. }
  30. }
  31. func TestMinifyContentWithSpecialComments(t *testing.T) {
  32. input := `<p>Some text <!--[if IE 6]><p>IE6</p><![endif]--> with a <a href="http://example.org/">link</a>.</p>`
  33. expected := `<p>Some text with a <a href="http://example.org/">link</a>.</p>`
  34. result := minifyContent(input)
  35. if expected != result {
  36. t.Errorf(`Unexpected result, got %q`, result)
  37. }
  38. }