Skip to content

Commit

Permalink
Deploy motorro/RxLceModel to github.com/motorro/RxLceModel.git:master
Browse files Browse the repository at this point in the history
  • Loading branch information
traviscibot committed Jun 7, 2020
1 parent d0a70f5 commit edc2b8b
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions base/src/test/kotlin/com/motorro/rxlcemodel/base/LceUtilsKtTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ package com.motorro.rxlcemodel.base
import io.reactivex.Completable
import io.reactivex.Observable
import io.reactivex.Single
import io.reactivex.subjects.BehaviorSubject
import io.reactivex.subjects.PublishSubject
import org.junit.Test
import java.io.IOException

Expand Down Expand Up @@ -224,6 +226,35 @@ class LceUtilsKtTest {
)
}


@Test
fun createsRefreshingStream() {
val value1 = LceState.Content(1, true)
val value2 = LceState.Content(2, true)
val refreshStream = PublishSubject.create<Int>()
val model = object : LceModel<Int, String> {
val stateSubject = BehaviorSubject.createDefault<LceState<Int>>(value1)
var refreshed = false

override val state: Observable<LceState<Int>> = stateSubject
override val refresh: Completable = Completable.fromAction {
refreshed = true
stateSubject.onNext(value2)
}
override val params: String = PARAMS
}

val observer = model.withRefresh(refreshStream).test()
observer.assertNotComplete()
observer.assertNoErrors()
observer.assertValues(value1)

refreshStream.onNext(1)
observer.assertNotComplete()
observer.assertNoErrors()
observer.assertValues(value1, value2)
}

@Test
fun substitutesEmptyLoading() {
val original = LceState.Loading(null, false)
Expand Down

0 comments on commit edc2b8b

Please sign in to comment.