1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-09-15 18:57:04 +00:00

Add addDynamicIframe rewrite function.

Add unit tests for `add_dynamic_iframe` rewrite.
This commit is contained in:
Dave 2024-01-21 21:28:21 -05:00 committed by Frédéric Guillot
parent 50341759b6
commit 1159dd6982
3 changed files with 87 additions and 0 deletions

View file

@ -333,6 +333,54 @@ func TestRewriteWithImageAndLazySrcset(t *testing.T) {
}
}
func TestRewriteWithNoLazyIframe(t *testing.T) {
controlEntry := &model.Entry{
Title: `A title`,
Content: `<iframe src="https://example.org/embed" allowfullscreen></iframe>`,
}
testEntry := &model.Entry{
Title: `A title`,
Content: `<iframe src="https://example.org/embed" allowfullscreen></iframe>`,
}
Rewriter("https://example.org/article", testEntry, "add_dynamic_iframe")
if !reflect.DeepEqual(testEntry, controlEntry) {
t.Errorf(`Not expected output: got "%+v" instead of "%+v"`, testEntry, controlEntry)
}
}
func TestRewriteWithLazyIframe(t *testing.T) {
controlEntry := &model.Entry{
Title: `A title`,
Content: `<iframe data-src="https://example.org/embed" allowfullscreen="" src="https://example.org/embed"></iframe>`,
}
testEntry := &model.Entry{
Title: `A title`,
Content: `<iframe data-src="https://example.org/embed" allowfullscreen></iframe>`,
}
Rewriter("https://example.org/article", testEntry, "add_dynamic_iframe")
if !reflect.DeepEqual(testEntry, controlEntry) {
t.Errorf(`Not expected output: got "%+v" instead of "%+v"`, testEntry, controlEntry)
}
}
func TestRewriteWithLazyIframeAndSrc(t *testing.T) {
controlEntry := &model.Entry{
Title: `A title`,
Content: `<iframe src="https://example.org/embed" data-src="https://example.org/embed" allowfullscreen=""></iframe>`,
}
testEntry := &model.Entry{
Title: `A title`,
Content: `<iframe src="about:blank" data-src="https://example.org/embed" allowfullscreen></iframe>`,
}
Rewriter("https://example.org/article", testEntry, "add_dynamic_iframe")
if !reflect.DeepEqual(testEntry, controlEntry) {
t.Errorf(`Not expected output: got "%+v" instead of "%+v"`, testEntry, controlEntry)
}
}
func TestNewLineRewriteRule(t *testing.T) {
controlEntry := &model.Entry{
Title: `A title`,