package be.kuleuven.howlongtobeat.cartridges
import junit.framework.TestCase.assertEquals
import org.junit.Test
import junit.framework.TestCase.assertNull as assertNull1
class DuckDuckGoResultParserTest {
@Test
fun parse_marioGolfCodeSample() {
val html = """
""".trimIndent()
val cart = DuckDuckGoResultParser.parse(html, "cgb-awxp-eur-1")
assertEquals("mario golf", cart?.title)
}
@Test
fun parse_NoResultsFound_returnsNull() {
val result = DuckDuckGoResultParser.parse("whooptie-doo", "some-code")
assertNull1(result)
}
@Test
fun parse_ResultWithStuffBetweenBrackets_removesThose() {
val html = """
My Little Pony (USA Release)!
""".trimIndent()
val cart = DuckDuckGoResultParser.parse(html, "some-code")
assertEquals("my little pony", cart?.title)
}
@Test
fun parse_ResultWithCodeAgainInResult_removesRedundantCode() {
val html = """
My Little Pony (USA Release) DMG-PONY-007 ebay
""".trimIndent()
val cart = DuckDuckGoResultParser.parse(html, "DMG-PONY-007")
assertEquals("my little pony", cart?.title)
assertEquals("DMG-PONY-007", cart?.code)
}
}