Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Jawnnypoo committed Jan 4, 2024
1 parent 66404c6 commit ad5b40b
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 48 deletions.
14 changes: 7 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ compose = "1.5.3"

androidX = "1.2.0"
lifecycle = "2.2.0"
lifecycleKtx = '2.4.0-alpha03'
lifecycleKtx = '2.6.2'
androidTest = "1.4.0"
espresso = "3.4.0"
robolectric = "4.11.1"
lint = "30.0.0"
autoService = "1.0-rc7"
lint = "31.2.0"
autoService = "1.1.1"

[libraries]
android-gradle = { module = "com.android.tools.build:gradle", version.ref = "android-gradle" }
kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
dokka-gradle = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka-gradle" }
dokka-android-gradle = { module = "org.jetbrains.dokka:android-documentation-plugin", version.ref = "dokka-gradle" }
maven-publish-gradle = { module = "com.vanniktech:gradle-maven-publish-plugin", version = "0.14.2" }
version-gradle = { module = "com.github.ben-manes:gradle-versions-plugin", version = "0.38.0" }
version-gradle = { module = "com.github.ben-manes:gradle-versions-plugin", version = "0.36.0" }

# We need to fork the plugin to fix an incorrect usage of tasks.withType(Test)
# https://github.com/vanniktech/gradle-android-junit-jacoco-plugin/compare/master...Laimiux:gradle-android-junit-jacoco-plugin:laimonas/gradle-8?expand=1
Expand Down Expand Up @@ -56,15 +56,15 @@ lifecycle-runtime-ktx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", v
espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "espresso" }
robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" }

rxjava = { module = "io.reactivex.rxjava3:rxjava", version = "3.1.1" }
rxjava = { module = "io.reactivex.rxjava3:rxjava", version = "3.1.6" }
rxandroid = { module = "io.reactivex.rxjava3:rxandroid", version = "3.0.0" }
rxrelay = { module = "com.jakewharton.rxrelay3:rxrelay", version = "3.0.1" }

truth = { module = "com.google.truth:truth", version = "1.1.3" }
truth = { module = "com.google.truth:truth", version = "1.1.5" }
junit = { module = "junit:junit", version = "4.13.2" }
rxrelays = { module = "com.jakewharton.rxrelay3:rxrelay", version = "3.0.1" }

mockito-core = { module = "org.mockito:mockito-core", version = "5.7.0" }
mockito-core = { module = "org.mockito:mockito-core", version = "5.8.0" }
mockito-kotlin = { module = "org.mockito.kotlin:mockito-kotlin", version = "5.2.1" }

lint-core = { module = "com.android.tools.lint:lint", version.ref = "lint" }
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
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
2 changes: 1 addition & 1 deletion jacoco.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Should match with what we run in .circleci/config.yml
# Should match with what we run in .github/workflows/build-workflow.yml
./gradlew clean
./gradlew :formula:test
./gradlew :formula-android:testRelease
Expand Down
3 changes: 2 additions & 1 deletion jitpack.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
jdk: openjdk11
jdk:
- openjdk18
2 changes: 0 additions & 2 deletions samples/todoapp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ dependencies {

testImplementation(libs.junit)
testImplementation(libs.truth)
testImplementation(libs.mockito.core)
testImplementation(libs.mockito.kotlin)
testImplementation(libs.kotlin.reflect)
testImplementation(project(":formula-test"))
testImplementation(libs.androidx.test.runner)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package com.examples.todoapp

import com.examples.todoapp.data.TaskRepo
import com.examples.todoapp.data.TaskRepoImpl
import com.examples.todoapp.tasks.TaskListFeatureFactory
import com.examples.todoapp.tasks.TaskListFormula
import com.instacart.formula.android.ActivityStoreContext

class TodoAppComponent(
private val store: ActivityStoreContext<TodoActivity>
) : TaskListFeatureFactory.Dependencies {
private val repo: TaskRepo = TaskRepo()

private val repo: TaskRepo = TaskRepoImpl()

override fun taskRepo(): TaskRepo {
return repo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,12 @@ import com.examples.todoapp.tasks.TaskCompletedEvent
import com.jakewharton.rxrelay3.BehaviorRelay
import io.reactivex.rxjava3.core.Observable
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.core.Scheduler
import java.util.concurrent.TimeUnit

class TaskRepo {
private val localStore: BehaviorRelay<List<Task>> = BehaviorRelay.createDefault(
listOf(
Task("Mow the lawn."),
Task("Go get a haircut.")
)
)
interface TaskRepo {

fun tasks(): Observable<List<Task>> {
// Fake initial network request
return Observable.timer(5, TimeUnit.SECONDS).observeOn(AndroidSchedulers.mainThread()).flatMap {
localStore
}
}
fun tasks(): Observable<List<Task>>

fun onTaskCompleted(event: TaskCompletedEvent) {
val updated = localStore.value!!.map {
if (it.id == event.taskId) {
it.copy(isCompleted = event.isCompleted)
} else {
it
}
}

localStore.accept(updated)
}
fun onTaskCompleted(event: TaskCompletedEvent)
}
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
Expand Up @@ -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>()
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`() {
val repo = TaskRepoFake()

TaskListFormula(repo)
.test(TaskListFormula.Input(showToast = {}))
.test(TaskListFormula.Input(showToast = showToast))
.output {
assertThat(items).hasSize(2)
}
Expand All @@ -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
}
}
}

0 comments on commit ad5b40b

Please sign in to comment.