Skip to content

Commit f0f3eb4

Browse files
Add missing test
1 parent d8112bb commit f0f3eb4

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

app/src/test/kotlin/app/fyreplace/fyreplace/test/screens/RegisterViewModelTests.kt

+17
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,28 @@ class RegisterViewModelTests : TestsBase() {
8686
viewModel.updateEmail("email")
8787
runCurrent()
8888
assertFalse(viewModel.canSubmit.value)
89+
8990
viewModel.updateEmail("email@example")
9091
runCurrent()
9192
assertTrue(viewModel.canSubmit.value)
9293
}
9394

95+
@Test
96+
fun `Terms must be accepted`() = runTest {
97+
val (_, _, viewModel) = makeViewModel(FakeEventBus())
98+
viewModel.updateUsername(FakeUsersEndpointApi.GOOD_USERNAME)
99+
viewModel.updateEmail(FakeUsersEndpointApi.GOOD_EMAIL)
100+
backgroundScope.launch { viewModel.canSubmit.collect() }
101+
102+
viewModel.updateHasAcceptedTerms(false)
103+
runCurrent()
104+
assertFalse(viewModel.canSubmit.value)
105+
106+
viewModel.updateHasAcceptedTerms(true)
107+
runCurrent()
108+
assertTrue(viewModel.canSubmit.value)
109+
}
110+
94111
@Test
95112
fun `Invalid username produces a failure`() = runTest {
96113
val eventBus = FakeEventBus()

0 commit comments

Comments
 (0)