From 3c2696ac679bc1dc66eecf6bc300d0d8570d50e7 Mon Sep 17 00:00:00 2001 From: mike castleman Date: Sat, 1 Jun 2019 15:29:33 -0400 Subject: [PATCH] add tests --- .../keylesspalace/tusky/util/RickRollTest.kt | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 app/src/test/java/com/keylesspalace/tusky/util/RickRollTest.kt diff --git a/app/src/test/java/com/keylesspalace/tusky/util/RickRollTest.kt b/app/src/test/java/com/keylesspalace/tusky/util/RickRollTest.kt new file mode 100644 index 00000000..6a6a5d53 --- /dev/null +++ b/app/src/test/java/com/keylesspalace/tusky/util/RickRollTest.kt @@ -0,0 +1,34 @@ +package com.keylesspalace.tusky.util + +import android.app.Activity +import androidx.test.ext.junit.runners.AndroidJUnit4 +import com.keylesspalace.tusky.FakeTuskyApplication +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.Robolectric +import org.robolectric.annotation.Config + +@Config(application = FakeTuskyApplication::class) +@RunWith(AndroidJUnit4::class) +class RickRollTest { + private lateinit var activity: Activity + @Before + fun setupActivity() { + val controller = Robolectric.buildActivity(Activity::class.java) + activity = controller.get() + } + + @Test + fun testShouldRickRoll() { + listOf("gab.Com", "social.gab.ai", "whatever.GAB.com").forEach { + rollableDomain -> assertTrue(shouldRickRoll(activity, rollableDomain)) + } + + listOf("chaos.social", "notgab.com").forEach { + notRollableDomain -> assertFalse(shouldRickRoll(activity, notRollableDomain)) + } + } +}