-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update dependencies #328
Update dependencies #328
Changes from 1 commit
ad5b40b
e2d378e
20cd0de
43a41f0
2006bed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Wed Dec 13 14:59:32 PST 2023 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
jdk: openjdk11 | ||
jdk: | ||
- openjdk18 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.examples.todoapp.data | ||
|
||
import com.examples.todoapp.tasks.TaskCompletedEvent | ||
import com.jakewharton.rxrelay3.BehaviorRelay | ||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers | ||
import io.reactivex.rxjava3.core.Observable | ||
import java.util.concurrent.TimeUnit | ||
|
||
class TaskRepoImpl : TaskRepo { | ||
private val localStore: BehaviorRelay<List<Task>> = BehaviorRelay.createDefault( | ||
listOf( | ||
Task("Mow the lawn."), | ||
Task("Go get a haircut.") | ||
) | ||
) | ||
|
||
override fun tasks(): Observable<List<Task>> { | ||
// Fake initial network request | ||
return Observable.timer(5, TimeUnit.SECONDS).observeOn(AndroidSchedulers.mainThread()).flatMap { | ||
localStore | ||
} | ||
} | ||
|
||
override fun onTaskCompleted(event: TaskCompletedEvent) { | ||
val updated = localStore.value!!.map { | ||
if (it.id == event.taskId) { | ||
it.copy(isCompleted = event.isCompleted) | ||
} else { | ||
it | ||
} | ||
} | ||
|
||
localStore.accept(updated) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,24 +4,21 @@ import com.examples.todoapp.data.Task | |
import com.examples.todoapp.data.TaskRepo | ||
import com.google.common.truth.Truth.assertThat | ||
import com.instacart.formula.test.test | ||
import com.nhaarman.mockito_kotlin.mock | ||
import com.nhaarman.mockito_kotlin.whenever | ||
import io.reactivex.rxjava3.core.Observable | ||
import org.junit.Test | ||
|
||
class TaskListFormulaTest { | ||
|
||
@Test fun `change filter type`() { | ||
val repo = mock<TaskRepo>() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for removing mocking |
||
whenever(repo.tasks()).thenReturn(Observable.just( | ||
listOf( | ||
Task("Mow the lawn."), | ||
Task("Go get a haircut.") | ||
) | ||
)) | ||
private val showToast = { toast: String -> | ||
|
||
} | ||
|
||
@Test | ||
fun `change filter type`() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wasn't sure if we wanted to keep this test around, it doesn't currently run in CI There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would like to keep it as an example |
||
val repo = TaskRepoFake() | ||
|
||
TaskListFormula(repo) | ||
.test(TaskListFormula.Input(showToast = {})) | ||
.test(TaskListFormula.Input(showToast = showToast)) | ||
.output { | ||
assertThat(items).hasSize(2) | ||
} | ||
|
@@ -32,4 +29,19 @@ class TaskListFormulaTest { | |
assertThat(items).isEmpty() | ||
} | ||
} | ||
|
||
class TaskRepoFake : TaskRepo { | ||
override fun tasks(): Observable<List<Task>> { | ||
return Observable.just( | ||
listOf( | ||
Task("Mow the lawn."), | ||
Task("Go get a haircut.") | ||
) | ||
) | ||
} | ||
|
||
override fun onTaskCompleted(event: TaskCompletedEvent) { | ||
// nothing to do | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Downgrade?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops 🙈