-
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.
Merge pull request #26 from tinkoff-mobile-tech/MC-6744
MС-6744 improve test coverage
- Loading branch information
Showing
2 changed files
with
125 additions
and
47 deletions.
There are no files selected for viewing
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
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) | ||
} | ||
} |