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
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.tv.firefox.ext
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Ignore
import org.junit.Test
class StringKtTest {
@Test
fun `WHEN youtube TV pages are entered THEN it is a youtube TV uri`() {
arrayOf(
"https://www.youtube.com/tv#/", // initial home page redirect
).forEach {
assertTrue(it, it.isUriYouTubeTV)
}
}
@Test
fun `WHEN youtube TV with capitals pages are entered THEN it is a youtube TV uri`() {
arrayOf(
"https://www.youtube.com/TV#/surface?c=FEtopics&resume" // YOUTUBE.COM/TV will redirect to this
).forEach {
assertTrue(it, it.isUriYouTubeTV)
}
}
@Test
fun `WHEN a youtube TV string contains leading or trailing spaces THEN it is a youtube TV uri`() {
arrayOf(
).forEach {
assertTrue(it, it.isUriYouTubeTV)
}
}
@Test
fun `WHEN tv dot youtube pages are entered THEN it is not a youtube TV uri`() {
arrayOf(
).forEach {
assertFalse(it, it.isUriYouTubeTV)
}
}
@Test
fun `WHEN youtube desktop pages are entered THEN it is not a youtube TV uri`() {
arrayOf(
"https://www.youtube.com/", // home page
).forEach {
assertFalse(it, it.isUriYouTubeTV)
}
}
@Test
fun `WHEN youtube mobile pages are entered THEN it is not a youtube TV uri`() {
arrayOf(
"https://m.youtube.com/", // home page
).forEach {
assertFalse(it, it.isUriYouTubeTV)
}
}
@Test
fun `WHEN non-youtube pages are entered THEN it is not a youtube TV uri`() {
arrayOf(
).forEach {
assertFalse(it, it.isUriYouTubeTV)
}
}
@Test
fun `WHEN bad urls are entered THEN it is not a youtube TV uri`() {
arrayOf(
"",
" ",
"not-a-uri"
).forEach {
assertFalse(it, it.isUriYouTubeTV)
}
}
@Ignore("this fails. We should fix it by moving to the Uri class.")
@Test
fun `WHEN non youtube TV uris containing youtube tv uri str are entered THEN it is not a youtube TV uri`() {
arrayOf(
).forEach {
assertFalse(it, it.isUriYouTubeTV)
}
}
}