Revision control
Copy as Markdown
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
package org.mozilla.tv.firefox.ext
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.tv.firefox.helpers.FirefoxRobolectricTestRunner
@RunWith(FirefoxRobolectricTestRunner::class)
class StringTest {
@Test
fun testBeautifyUrl() {
assertEqualsBeautified(
"wikipedia.org/wiki/Adler_Planetarium",
assertEqualsBeautified(
"youtube.com/watch?v=WXqGDW7kuAk",
assertEqualsBeautified(
"spotify.com/album/6JVdzwuTEaLj7Tga8DpFpz",
assertEqualsBeautified(
"google.com/mail/…/0#inbox/15e34774924ddfb5",
assertEqualsBeautified(
"google.com/store/…/details?id=com.facebook.katana",
assertEqualsBeautified(
"amazon.com/Mockingjay-Hunger-Games-Suzanne-Collins/…/ref=pd_sim_14_2?_encoding=UTF8",
assertEqualsBeautified(
"usbank.com/Auth/Login",
assertEqualsBeautified(
"wsj.com/articles/mexican-presidential-candidate-calls-for-nafta-talks-to-be-suspended-1504137175",
assertEqualsBeautified(
"nytimes.com/2017/…/princess-diana-death-anniversary.html?hp",
assertEqualsBeautified(
"yahoo.co.jp/hl?a=20170830-00000008-jct-soci",
assertEqualsBeautified(
"tomshardware.co.uk/answers/…/running-guest-network-channel-interference.html",
assertEqualsBeautified(
"github.com/mozilla-mobile/…/1231",
}
private fun assertEqualsBeautified(expected: String, url: String) {
assertEquals("beautify($url)", expected, url.beautifyUrl())
}
}