package org.terst.feedreader.readability import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue import org.junit.Test /** * The single entry point both cleaning sites call. * * The thing worth testing is that it applies *every* cleaner, because the failure it exists to * prevent is a cleaner that only runs on one of the two paths. */ class ArticleLitterTest { private val recirculationWidget = """
""" + """

Trending

""" private val preferredSourceBadge = """

""" + """

""" @Test fun `removes both kinds of litter from one body`() { val html = "$preferredSourceBadge

Real sentence.

$recirculationWidget" val cleaned = ArticleLitter.strip(html)!! assertFalse("badge survived: $cleaned", cleaned.contains("preferences/source")) assertFalse("widget survived: $cleaned", cleaned.contains("Trending")) assertTrue(cleaned.contains("Real sentence.")) } @Test fun `leaves a clean article untouched`() { val html = "

Nothing to clean.

" assertEquals(html, ArticleLitter.strip(html)) } @Test fun `copes with nothing`() { assertEquals(null, ArticleLitter.strip(null)) } }