-
Notifications
You must be signed in to change notification settings - Fork 663
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into brnunes/alipay
- Loading branch information
Showing
21 changed files
with
225 additions
and
80 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 | |
import com.google.common.truth.Truth.assertThat | ||
import com.stripe.android.link.LinkScreen | ||
import com.stripe.android.link.R | ||
import com.stripe.android.link.model.AccountStatus | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
@@ -21,7 +22,8 @@ internal class LinkAppBarStateTest { | |
val state = buildLinkAppBarState( | ||
isRootScreen = true, | ||
currentRoute = LinkScreen.Wallet.route, | ||
email = " " | ||
email = " ", | ||
accountStatus = AccountStatus.SignedOut | ||
) | ||
|
||
assertThat(state.email).isNull() | ||
|
@@ -32,14 +34,16 @@ internal class LinkAppBarStateTest { | |
val state = buildLinkAppBarState( | ||
isRootScreen = true, | ||
currentRoute = LinkScreen.Loading.route, | ||
email = null | ||
email = null, | ||
accountStatus = AccountStatus.SignedOut | ||
) | ||
|
||
val expected = LinkAppBarState( | ||
navigationIcon = R.drawable.ic_link_close, | ||
showHeader = true, | ||
showOverflowMenu = false, | ||
email = null | ||
email = null, | ||
accountStatus = AccountStatus.SignedOut | ||
) | ||
|
||
assertThat(state).isEqualTo(expected) | ||
|
@@ -50,14 +54,16 @@ internal class LinkAppBarStateTest { | |
val state = buildLinkAppBarState( | ||
isRootScreen = true, | ||
currentRoute = LinkScreen.Verification.route, | ||
email = "[email protected]" | ||
email = "[email protected]", | ||
accountStatus = AccountStatus.VerificationStarted | ||
) | ||
|
||
val expected = LinkAppBarState( | ||
navigationIcon = R.drawable.ic_link_close, | ||
showHeader = true, | ||
showOverflowMenu = false, | ||
email = null | ||
email = null, | ||
accountStatus = AccountStatus.VerificationStarted | ||
) | ||
|
||
assertThat(state).isEqualTo(expected) | ||
|
@@ -68,14 +74,16 @@ internal class LinkAppBarStateTest { | |
val state = buildLinkAppBarState( | ||
isRootScreen = true, | ||
currentRoute = LinkScreen.VerificationDialog.route, | ||
email = "[email protected]" | ||
email = "[email protected]", | ||
accountStatus = AccountStatus.VerificationStarted | ||
) | ||
|
||
val expected = LinkAppBarState( | ||
navigationIcon = R.drawable.ic_link_close, | ||
showHeader = true, | ||
showOverflowMenu = false, | ||
email = "[email protected]" | ||
email = "[email protected]", | ||
accountStatus = AccountStatus.VerificationStarted | ||
) | ||
|
||
assertThat(state).isEqualTo(expected) | ||
|
@@ -86,14 +94,16 @@ internal class LinkAppBarStateTest { | |
val state = buildLinkAppBarState( | ||
isRootScreen = true, | ||
currentRoute = LinkScreen.Wallet.route, | ||
email = "[email protected]" | ||
email = "[email protected]", | ||
accountStatus = AccountStatus.Verified | ||
) | ||
|
||
val expected = LinkAppBarState( | ||
navigationIcon = R.drawable.ic_link_close, | ||
showHeader = true, | ||
showOverflowMenu = true, | ||
email = "[email protected]" | ||
email = "[email protected]", | ||
accountStatus = AccountStatus.Verified | ||
) | ||
|
||
assertThat(state).isEqualTo(expected) | ||
|
@@ -104,14 +114,16 @@ internal class LinkAppBarStateTest { | |
val state = buildLinkAppBarState( | ||
isRootScreen = true, | ||
currentRoute = LinkScreen.PaymentMethod.route, | ||
email = "[email protected]" | ||
email = "[email protected]", | ||
accountStatus = AccountStatus.Verified | ||
) | ||
|
||
val expected = LinkAppBarState( | ||
navigationIcon = R.drawable.ic_link_close, | ||
showHeader = true, | ||
showOverflowMenu = true, | ||
email = "[email protected]" | ||
email = "[email protected]", | ||
accountStatus = AccountStatus.Verified | ||
) | ||
|
||
assertThat(state).isEqualTo(expected) | ||
|
@@ -122,14 +134,16 @@ internal class LinkAppBarStateTest { | |
val state = buildLinkAppBarState( | ||
isRootScreen = false, | ||
currentRoute = LinkScreen.PaymentMethod.route, | ||
email = "[email protected]" | ||
email = "[email protected]", | ||
accountStatus = AccountStatus.Verified | ||
) | ||
|
||
val expected = LinkAppBarState( | ||
navigationIcon = R.drawable.ic_link_back, | ||
showHeader = false, | ||
showOverflowMenu = false, | ||
email = null | ||
email = null, | ||
accountStatus = AccountStatus.Verified | ||
) | ||
|
||
assertThat(state).isEqualTo(expected) | ||
|
@@ -140,14 +154,16 @@ internal class LinkAppBarStateTest { | |
val state = buildLinkAppBarState( | ||
isRootScreen = false, | ||
currentRoute = LinkScreen.CardEdit.route, | ||
email = "[email protected]" | ||
email = "[email protected]", | ||
accountStatus = AccountStatus.Verified | ||
) | ||
|
||
val expected = LinkAppBarState( | ||
navigationIcon = R.drawable.ic_link_back, | ||
showHeader = false, | ||
showOverflowMenu = false, | ||
email = null | ||
email = null, | ||
accountStatus = AccountStatus.Verified | ||
) | ||
|
||
assertThat(state).isEqualTo(expected) | ||
|
@@ -158,14 +174,36 @@ internal class LinkAppBarStateTest { | |
val state = buildLinkAppBarState( | ||
isRootScreen = true, | ||
currentRoute = LinkScreen.SignUp.route, | ||
email = null | ||
email = null, | ||
accountStatus = AccountStatus.SignedOut | ||
) | ||
|
||
val expected = LinkAppBarState( | ||
navigationIcon = R.drawable.ic_link_close, | ||
showHeader = true, | ||
showOverflowMenu = false, | ||
email = null | ||
email = null, | ||
accountStatus = AccountStatus.SignedOut | ||
) | ||
|
||
assertThat(state).isEqualTo(expected) | ||
} | ||
|
||
@Test | ||
fun signupScreenShowsCorrectAppBarStateWithEmail() { | ||
val state = buildLinkAppBarState( | ||
isRootScreen = true, | ||
currentRoute = LinkScreen.SignUp.route, | ||
email = "[email protected]", | ||
accountStatus = AccountStatus.NeedsVerification | ||
) | ||
|
||
val expected = LinkAppBarState( | ||
navigationIcon = R.drawable.ic_link_close, | ||
showHeader = true, | ||
showOverflowMenu = false, | ||
email = null, | ||
accountStatus = AccountStatus.NeedsVerification | ||
) | ||
|
||
assertThat(state).isEqualTo(expected) | ||
|
@@ -174,12 +212,13 @@ internal class LinkAppBarStateTest { | |
private fun buildLinkAppBarState( | ||
isRootScreen: Boolean, | ||
currentRoute: String?, | ||
email: String? | ||
email: String?, | ||
accountStatus: AccountStatus? | ||
): LinkAppBarState { | ||
var state: LinkAppBarState? = null | ||
|
||
composeTestRule.setContent { | ||
state = rememberLinkAppBarState(isRootScreen, currentRoute, email) | ||
state = rememberLinkAppBarState(isRootScreen, currentRoute, email, accountStatus) | ||
} | ||
|
||
return state ?: throw AssertionError( | ||
|
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 |
---|---|---|
|
@@ -8,6 +8,7 @@ import androidx.compose.ui.test.performClick | |
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import com.google.common.truth.Truth.assertThat | ||
import com.stripe.android.link.R | ||
import com.stripe.android.link.model.AccountStatus | ||
import com.stripe.android.link.theme.DefaultLinkTheme | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
@@ -19,7 +20,7 @@ internal class LinkAppBarTest { | |
val composeTestRule = createAndroidComposeRule<ComponentActivity>() | ||
|
||
@Test | ||
fun email_is_shown_when_provided() { | ||
fun verified_email_is_shown_when_provided() { | ||
val email = "[email protected]" | ||
setContent(email) | ||
|
||
|
@@ -48,6 +49,7 @@ internal class LinkAppBarTest { | |
|
||
private fun setContent( | ||
email: String? = null, | ||
accountStatus: AccountStatus? = null, | ||
onBackPress: () -> Unit = {}, | ||
onLogout: () -> Unit = {}, | ||
showBottomSheetContent: (BottomSheetContent?) -> Unit = {} | ||
|
@@ -58,7 +60,8 @@ internal class LinkAppBarTest { | |
navigationIcon = R.drawable.ic_link_close, | ||
showHeader = true, | ||
showOverflowMenu = true, | ||
email = email | ||
email = email, | ||
accountStatus = accountStatus | ||
), | ||
onBackPressed = onBackPress, | ||
onLogout = onLogout, | ||
|
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
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
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
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 |
---|---|---|
|
@@ -27,6 +27,7 @@ import androidx.compose.ui.text.style.TextOverflow | |
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import com.stripe.android.link.R | ||
import com.stripe.android.link.model.AccountStatus | ||
import com.stripe.android.link.theme.AppBarHeight | ||
import com.stripe.android.link.theme.DefaultLinkTheme | ||
import com.stripe.android.link.theme.linkColors | ||
|
@@ -131,7 +132,8 @@ private fun LinkAppBarPreview() { | |
navigationIcon = R.drawable.ic_link_close, | ||
showHeader = true, | ||
showOverflowMenu = true, | ||
email = "[email protected]" | ||
email = "[email protected]", | ||
accountStatus = AccountStatus.Verified | ||
), | ||
onBackPressed = {}, | ||
onLogout = {}, | ||
|
@@ -151,7 +153,8 @@ private fun LinkAppBar_NoEmail() { | |
navigationIcon = R.drawable.ic_link_close, | ||
showHeader = true, | ||
showOverflowMenu = true, | ||
email = null | ||
email = null, | ||
accountStatus = AccountStatus.SignedOut | ||
), | ||
onBackPressed = {}, | ||
onLogout = {}, | ||
|
@@ -171,7 +174,8 @@ private fun LinkAppBar_ChildScreen() { | |
navigationIcon = R.drawable.ic_link_back, | ||
showHeader = false, | ||
showOverflowMenu = false, | ||
email = "[email protected]" | ||
email = "[email protected]", | ||
accountStatus = AccountStatus.Verified | ||
), | ||
onBackPressed = {}, | ||
onLogout = {}, | ||
|
@@ -191,7 +195,8 @@ private fun LinkAppBar_ChildScreen_NoEmail() { | |
navigationIcon = R.drawable.ic_link_back, | ||
showHeader = false, | ||
showOverflowMenu = false, | ||
email = null | ||
email = null, | ||
accountStatus = AccountStatus.SignedOut | ||
), | ||
onBackPressed = {}, | ||
onLogout = {}, | ||
|
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
Oops, something went wrong.