diff options
Diffstat (limited to 'app/src/test/kotlin/com/pitchedapps')
-rw-r--r-- | app/src/test/kotlin/com/pitchedapps/frost/facebook/FbUrlTest.kt | 39 | ||||
-rw-r--r-- | app/src/test/kotlin/com/pitchedapps/frost/utils/UrlTest.kt | 22 |
2 files changed, 39 insertions, 22 deletions
diff --git a/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbUrlTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbUrlTest.kt new file mode 100644 index 00000000..d7ec4b46 --- /dev/null +++ b/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbUrlTest.kt @@ -0,0 +1,39 @@ +package com.pitchedapps.frost.facebook + +import org.junit.Test +import kotlin.test.assertEquals + + +/** + * Created by Allan Wang on 2017-07-07. + */ +class FbUrlTest { + + @Test + fun base() { + val url = "https://touch.facebook.com/relative/?asdf=1234&hjkl=7890" + assertFbFormat(url, url) + } + + @Test + fun relative() { + val url = "/relative/?asdf=1234&hjkl=7890" + assertFbFormat("$FB_URL_BASE${url.substring(1)}", url) + } + + @Test + fun redirect() { + assertFbFormat("$FB_URL_BASE/relative/?asdf=1234&hjkl=7890", "https://touch.facebook.com/l.php?u=$FB_URL_BASE/relative/&asdf=1234&hjkl=7890") + } + + @Test fun discard() { + val prefix = "$FB_URL_BASE/?test=1234" + val suffix = "&apple=notorange" + assertFbFormat("$prefix$suffix", "$prefix&ref=hello$suffix") + } + + fun assertFbFormat(expected: String, url: String) { + val fbUrl = FbUrlFormatter(url) + assertEquals(expected, fbUrl.toString(), "FbUrl Mismatch:\n${fbUrl.toLogList().joinToString("\n\t")}") + } +}
\ No newline at end of file diff --git a/app/src/test/kotlin/com/pitchedapps/frost/utils/UrlTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/utils/UrlTest.kt deleted file mode 100644 index 3590e625..00000000 --- a/app/src/test/kotlin/com/pitchedapps/frost/utils/UrlTest.kt +++ /dev/null @@ -1,22 +0,0 @@ -package com.pitchedapps.frost.utils - -import com.pitchedapps.frost.facebook.FbUrlFormatter -import org.junit.Test - - -/** - * Created by Allan Wang on 2017-07-07. - */ -class UrlTest { - - @Test - fun testParse() { - val url = FbUrlFormatter(TEST_URL) - url.log() - println(url.toString()) - } - - private fun FbUrlFormatter.log() = toLogList().forEach { println(it) } -} - -const val TEST_URL = "https://touch.facebook.com/ScienceOrientationWeek/?refid=52&_ft_=qid.6440135786032091148%3Amf_story_key.3325631938086219467%3Atop_level_post_id.1555752904487229%3Apage_id.525538540842009&__tn__=C"
\ No newline at end of file |