From 3de31a1a4d3ae31543af5f9b1112c46078ebc5f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Sun, 29 Jun 2025 12:48:50 -0700 Subject: [PATCH] test(processor): add more unit tests for `minifyContent` function --- internal/reader/processor/processor_test.go | 17 -------- internal/reader/processor/utils_test.go | 44 +++++++++++++++++++++ 2 files changed, 44 insertions(+), 17 deletions(-) delete mode 100644 internal/reader/processor/processor_test.go create mode 100644 internal/reader/processor/utils_test.go diff --git a/internal/reader/processor/processor_test.go b/internal/reader/processor/processor_test.go deleted file mode 100644 index 99a182c2..00000000 --- a/internal/reader/processor/processor_test.go +++ /dev/null @@ -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 := `

Some text with a link

` - expected := `

Some text with a link

` - result := minifyContent(input) - if expected != result { - t.Errorf(`Unexpected result, got %q`, result) - } -} diff --git a/internal/reader/processor/utils_test.go b/internal/reader/processor/utils_test.go new file mode 100644 index 00000000..5eac6254 --- /dev/null +++ b/internal/reader/processor/utils_test.go @@ -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 := `

Some text with a link

` + expected := `

Some text with a link

` + result := minifyContent(input) + if expected != result { + t.Errorf(`Unexpected result, got %q`, result) + } +} + +func TestMinifyContentWithDefaultAttributes(t *testing.T) { + input := `` + expected := `` + result := minifyContent(input) + if expected != result { + t.Errorf(`Unexpected result, got %q`, result) + } +} + +func TestMinifyContentWithComments(t *testing.T) { + input := `

Some text with a link.

` + expected := `

Some text with a link.

` + result := minifyContent(input) + if expected != result { + t.Errorf(`Unexpected result, got %q`, result) + } +} + +func TestMinifyContentWithSpecialComments(t *testing.T) { + input := `

Some text with a link.

` + expected := `

Some text with a link.

` + result := minifyContent(input) + if expected != result { + t.Errorf(`Unexpected result, got %q`, result) + } +}