-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kirill Voskrebentsev
committed
May 23, 2023
1 parent
8b96c72
commit 0780d9c
Showing
1 changed file
with
80 additions
and
0 deletions.
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
tinkoff-id/src/test/java/ru/tinkoff/core/tinkoffId/TinkoffIdSignInButtonTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package ru.tinkoff.core.tinkoffId | ||
|
||
import android.content.Context | ||
import android.os.Build | ||
import android.text.SpannedString | ||
import androidx.core.content.res.ResourcesCompat | ||
import androidx.test.core.app.ApplicationProvider | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Before | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.robolectric.RobolectricTestRunner | ||
import org.robolectric.annotation.Config | ||
import ru.tinkoff.core.tinkoffId.ui.TinkoffDimen | ||
import ru.tinkoff.core.tinkoffId.ui.TinkoffIdSignInButton | ||
|
||
/** | ||
* @author k.voskrebentsev | ||
*/ | ||
@Config(sdk = [Build.VERSION_CODES.P]) | ||
@RunWith(RobolectricTestRunner::class) | ||
internal class TinkoffIdSignInButtonTest { | ||
|
||
private lateinit var button: TinkoffIdSignInButton | ||
|
||
@Before | ||
fun setUp() { | ||
button = TinkoffIdSignInButton(context = context) | ||
} | ||
|
||
@Test | ||
fun testSetEmptyTitle() { | ||
button.title = "" | ||
|
||
val result = button.title as SpannedString | ||
|
||
assertEquals(PERMANENT_TITLE_PART, result.toString()) | ||
} | ||
|
||
@Test | ||
fun testSetTitle() { | ||
button.title = CUSTOM_TITLE_PART | ||
|
||
val result = button.title as SpannedString | ||
|
||
assertEquals("$CUSTOM_TITLE_PART $PERMANENT_TITLE_PART", result.toString()) | ||
} | ||
|
||
@Test | ||
fun testDefaultBadgeText() { | ||
assertEquals("", button.badgeText) | ||
} | ||
|
||
@Test | ||
fun testDefaultCompact() { | ||
assertEquals(false, button.isCompact) | ||
} | ||
|
||
@Test | ||
fun testDefaultStyle() { | ||
assertEquals(TinkoffIdSignInButton.ButtonStyle.YELLOW, button.style) | ||
} | ||
|
||
@Test | ||
fun testDefaultCornerSize() { | ||
assertEquals(context.resources.getDimension(TinkoffDimen.tinkoff_id_default_corner_radius).toInt(), button.cornerRadius) | ||
} | ||
|
||
@Test | ||
fun testDefaultFont() { | ||
assertEquals(ResourcesCompat.getFont(context, R.font.neue_haas_unica_w1g), button.textFont) | ||
} | ||
|
||
companion object { | ||
val context: Context = ApplicationProvider.getApplicationContext() | ||
|
||
const val CUSTOM_TITLE_PART = "title" | ||
val PERMANENT_TITLE_PART = context.getString(R.string.tinkoff_id_tinkoff_text) | ||
} | ||
} |