Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add logout menu in Link wallet (#5470)
* Add logout menu in Link wallet * Add tests * Update API * Fix lint issue * Fix rebase issue
- Loading branch information
1 parent
d455d48
commit 435d2ba
Showing
13 changed files
with
281 additions
and
32 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
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
58 changes: 58 additions & 0 deletions
58
link/src/androidTest/java/com/stripe/android/link/ui/LinkLogoutSheetTest.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,58 @@ | ||
package com.stripe.android.link.ui | ||
|
||
import androidx.activity.ComponentActivity | ||
import androidx.compose.ui.test.junit4.createAndroidComposeRule | ||
import androidx.compose.ui.test.onNodeWithText | ||
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.theme.DefaultLinkTheme | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class LinkLogoutSheetTest { | ||
|
||
@get:Rule | ||
val composeTestRule = createAndroidComposeRule<ComponentActivity>() | ||
|
||
@Test | ||
fun on_logout_button_click_callback_is_called() { | ||
val clickRecorder = MockClickRecorder() | ||
setContent(clickRecorder) | ||
|
||
composeTestRule.onNodeWithText("Log out of Link").performClick() | ||
|
||
assertThat(clickRecorder).isEqualTo(MockClickRecorder(logoutClicked = true)) | ||
} | ||
|
||
@Test | ||
fun on_cancel_button_click_callback_is_called() { | ||
val clickRecorder = MockClickRecorder() | ||
setContent(clickRecorder) | ||
|
||
composeTestRule.onNodeWithText("Cancel").performClick() | ||
|
||
assertThat(clickRecorder).isEqualTo(MockClickRecorder(cancelClicked = true)) | ||
} | ||
|
||
private fun setContent( | ||
clickRecorder: MockClickRecorder | ||
) = composeTestRule.setContent { | ||
DefaultLinkTheme { | ||
LinkLogoutSheet( | ||
onLogoutClick = clickRecorder::onLogoutClicked, | ||
onCancelClick = clickRecorder::onCancelClick | ||
) | ||
} | ||
} | ||
|
||
private data class MockClickRecorder( | ||
var logoutClicked: Boolean = false, | ||
var cancelClicked: Boolean = false | ||
) { | ||
fun onLogoutClicked() { logoutClicked = true } | ||
fun onCancelClick() { cancelClicked = true } | ||
} | ||
} |
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
Oops, something went wrong.