diff options
author | Allan Wang <me@allanwang.ca> | 2020-03-01 23:00:09 -0800 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2020-03-01 23:00:09 -0800 |
commit | e19c87ae367154bd5bbf59f080eee4976e64e2da (patch) | |
tree | 52f30b2d97dee998aabe46feffc1f4999275ec42 /app/src/test/kotlin | |
parent | 10d6cfdecb790e235e09641b18b4a10a645f87a0 (diff) | |
download | frost-e19c87ae367154bd5bbf59f080eee4976e64e2da.tar.gz frost-e19c87ae367154bd5bbf59f080eee4976e64e2da.tar.bz2 frost-e19c87ae367154bd5bbf59f080eee4976e64e2da.zip |
Format code
Diffstat (limited to 'app/src/test/kotlin')
7 files changed, 41 insertions, 12 deletions
diff --git a/app/src/test/kotlin/com/pitchedapps/frost/debugger/OfflineWebsiteTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/debugger/OfflineWebsiteTest.kt index 20c0878f..4064a5ff 100644 --- a/app/src/test/kotlin/com/pitchedapps/frost/debugger/OfflineWebsiteTest.kt +++ b/app/src/test/kotlin/com/pitchedapps/frost/debugger/OfflineWebsiteTest.kt @@ -137,7 +137,9 @@ class OfflineWebsiteTest { server.dispatcher = object : Dispatcher() { override fun dispatch(request: RecordedRequest): MockResponse = when { - request.path?.contains(cssUrl.encodedPath) == true -> MockResponse().setBody(css1) + request.path?.contains(cssUrl.encodedPath) == true -> MockResponse().setBody( + css1 + ) else -> MockResponse().setBody(content) } } diff --git a/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbRegexTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbRegexTest.kt index fc96ef2e..08957ea9 100644 --- a/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbRegexTest.kt +++ b/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbRegexTest.kt @@ -27,7 +27,8 @@ class FbRegexTest { @Test fun userIdRegex() { val id = 12349876L - val cookie = "wd=1366x615; c_user=$id; act=1234%2F12; m_pixel_ratio=1; presence=hello; x-referer=asdfasdf" + val cookie = + "wd=1366x615; c_user=$id; act=1234%2F12; m_pixel_ratio=1; presence=hello; x-referer=asdfasdf" assertEquals(id, FB_USER_MATCHER.find(cookie)[1]?.toLong()) } @@ -41,13 +42,17 @@ class FbRegexTest { @Test fun ppRegex() { - val img = "https\\3a //scontent-yyz1-1.xx.fbcdn.net/v/asdf1234.jpg?efg\\3d 333\\26 oh\\3d 77\\26 oe\\3d 444" + val img = + "https\\3a //scontent-yyz1-1.xx.fbcdn.net/v/asdf1234.jpg?efg\\3d 333\\26 oh\\3d 77\\26 oe\\3d 444" val imgUnescaped = StringEscapeUtils.unescapeCsv(img) val ppStyleSingleQuote = "background:#d8dce6 url('$img') no-repeat center;" val ppStyleDoubleQuote = "background:#d8dce6 url(\"$img\") no-repeat center;" val ppStyleNoQuote = "background:#d8dce6 url($img) no-repeat center;" listOf(ppStyleSingleQuote, ppStyleDoubleQuote, ppStyleNoQuote).forEach { - assertEquals(imgUnescaped, StringEscapeUtils.unescapeCsv(FB_CSS_URL_MATCHER.find(it)[1])) + assertEquals( + imgUnescaped, + StringEscapeUtils.unescapeCsv(FB_CSS_URL_MATCHER.find(it)[1]) + ) } } @@ -55,9 +60,17 @@ class FbRegexTest { fun msgNotifIdRegex() { val id = 1273491646093428L val data = "threadlist_row_other_user_fbid_thread_fbid_$id" - assertEquals(id, FB_MESSAGE_NOTIF_ID_MATCHER.find(data)[1]?.toLong(), "thread_fbid mismatch") + assertEquals( + id, + FB_MESSAGE_NOTIF_ID_MATCHER.find(data)[1]?.toLong(), + "thread_fbid mismatch" + ) val userData = "threadlist_row_other_user_fbid_${id}thread_fbid_" - assertEquals(id, FB_MESSAGE_NOTIF_ID_MATCHER.find(userData)[1]?.toLong(), "user_fbid mismatch") + assertEquals( + id, + FB_MESSAGE_NOTIF_ID_MATCHER.find(userData)[1]?.toLong(), + "user_fbid mismatch" + ) } @Test @@ -70,7 +83,8 @@ class FbRegexTest { @Test fun imageIdRegex() { val id = 123456L - val img = "https://scontent-yyz1-1.xx.fbcdn.net/v/t31.0-8/fr/cp0/e15/q65/89056_${id}_98239_o.jpg" + val img = + "https://scontent-yyz1-1.xx.fbcdn.net/v/t31.0-8/fr/cp0/e15/q65/89056_${id}_98239_o.jpg" assertEquals(id, FB_IMAGE_ID_MATCHER.find(img)[1]?.toLongOrNull()) } } diff --git a/app/src/test/kotlin/com/pitchedapps/frost/internal/Internal.kt b/app/src/test/kotlin/com/pitchedapps/frost/internal/Internal.kt index b83cb62e..17ce847c 100644 --- a/app/src/test/kotlin/com/pitchedapps/frost/internal/Internal.kt +++ b/app/src/test/kotlin/com/pitchedapps/frost/internal/Internal.kt @@ -79,7 +79,10 @@ fun Any.assertComponentsNotEmpty() { val result = it.call(this) as String assertTrue(result.isNotEmpty(), "${it.name} returned empty string") if (result.startsWith("https")) - assertTrue(result.startsWith("https://"), "${it.name} has poorly formatted output $result") + assertTrue( + result.startsWith("https://"), + "${it.name} has poorly formatted output $result" + ) } } } diff --git a/app/src/test/kotlin/com/pitchedapps/frost/kotlin/FlyweightTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/kotlin/FlyweightTest.kt index bcc86974..20cdd5ec 100644 --- a/app/src/test/kotlin/com/pitchedapps/frost/kotlin/FlyweightTest.kt +++ b/app/src/test/kotlin/com/pitchedapps/frost/kotlin/FlyweightTest.kt @@ -107,7 +107,10 @@ class FlyweightTest { } catch (ignore: CancellationException) { } try { - assertFalse(longRunningResult.isActive, "Long running result should no longer be active") + assertFalse( + longRunningResult.isActive, + "Long running result should no longer be active" + ) longRunningResult.await() fail("Flyweight should have cancelled previously running requests") } catch (ignore: CancellationException) { diff --git a/app/src/test/kotlin/com/pitchedapps/frost/utils/BuildUtilsTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/utils/BuildUtilsTest.kt index 7b1fcfcf..596693e7 100644 --- a/app/src/test/kotlin/com/pitchedapps/frost/utils/BuildUtilsTest.kt +++ b/app/src/test/kotlin/com/pitchedapps/frost/utils/BuildUtilsTest.kt @@ -28,7 +28,10 @@ class BuildUtilsTest { fun matchingVersions() { assertNull(BuildUtils.match("unknown")) assertEquals(BuildUtils.Data("v1.0.0", ""), BuildUtils.match("1.0.0")) - assertEquals(BuildUtils.Data("v2.0.1", "26-af40533-debug"), BuildUtils.match("2.0.1-26-af40533-debug")) + assertEquals( + BuildUtils.Data("v2.0.1", "26-af40533-debug"), + BuildUtils.match("2.0.1-26-af40533-debug") + ) } @Test diff --git a/app/src/test/kotlin/com/pitchedapps/frost/utils/CoroutineTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/utils/CoroutineTest.kt index 7faf2b67..cb427faa 100644 --- a/app/src/test/kotlin/com/pitchedapps/frost/utils/CoroutineTest.kt +++ b/app/src/test/kotlin/com/pitchedapps/frost/utils/CoroutineTest.kt @@ -61,7 +61,10 @@ class CoroutineTest { } } - private suspend fun <T> listen(channel: ReceiveChannel<T>, shouldEnd: suspend (T) -> Boolean = { false }): List<T> = + private suspend fun <T> listen( + channel: ReceiveChannel<T>, + shouldEnd: suspend (T) -> Boolean = { false } + ): List<T> = withContext(Dispatchers.IO) { val data = mutableListOf<T>() for (c in channel) { diff --git a/app/src/test/kotlin/com/pitchedapps/frost/utils/JsoupCleanerTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/utils/JsoupCleanerTest.kt index 13dc7ac6..7c277dc7 100644 --- a/app/src/test/kotlin/com/pitchedapps/frost/utils/JsoupCleanerTest.kt +++ b/app/src/test/kotlin/com/pitchedapps/frost/utils/JsoupCleanerTest.kt @@ -26,7 +26,8 @@ class JsoupCleanerTest { val whitespaceRegex = Regex("\\s+") - fun String.cleanWhitespace() = replace("\n", "").replace(whitespaceRegex, " ").replace("> <", "><") + fun String.cleanWhitespace() = + replace("\n", "").replace(whitespaceRegex, " ").replace("> <", "><") private fun String.assertCleanHtml(expected: String) { assertEquals(expected.cleanWhitespace(), cleanHtml().cleanWhitespace()) |