diff options
author | Robbie Cronin <robert.cronin@uqconnect.edu.au> | 2019-06-26 12:42:55 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-26 12:42:55 +0800 |
commit | d20bc8739b1ad58c1222d63258f01ef9e9d34064 (patch) | |
tree | 078b87746de4a305452224de39272529def43679 /kvision-modules/kvision-redux/src/test/kotlin | |
parent | 97d136f14f086cf457453f1c94da1ecdae835234 (diff) | |
parent | 1f5742bebbafbe20a9d7527794798db7ebe5ab98 (diff) | |
download | kvision-d20bc8739b1ad58c1222d63258f01ef9e9d34064.tar.gz kvision-d20bc8739b1ad58c1222d63258f01ef9e9d34064.tar.bz2 kvision-d20bc8739b1ad58c1222d63258f01ef9e9d34064.zip |
Merge pull request #2 from rjaros/master
pull version 0.0.37
Diffstat (limited to 'kvision-modules/kvision-redux/src/test/kotlin')
2 files changed, 9 insertions, 12 deletions
diff --git a/kvision-modules/kvision-redux/src/test/kotlin/test/pl/treksoft/kvision/redux/ReduxStoreSpec.kt b/kvision-modules/kvision-redux/src/test/kotlin/test/pl/treksoft/kvision/redux/ReduxStoreSpec.kt index 3be83556..b45eb9dd 100644 --- a/kvision-modules/kvision-redux/src/test/kotlin/test/pl/treksoft/kvision/redux/ReduxStoreSpec.kt +++ b/kvision-modules/kvision-redux/src/test/kotlin/test/pl/treksoft/kvision/redux/ReduxStoreSpec.kt @@ -21,15 +21,13 @@ */ package test.pl.treksoft.kvision.redux -import kotlinx.serialization.Serializable import pl.treksoft.kvision.redux.createReduxStore import redux.RAction import test.pl.treksoft.kvision.SimpleSpec import kotlin.test.Test import kotlin.test.assertEquals -@Serializable -data class TestState(val counter: Int) +data class TestState(val counter: Int, val values: List<Int>) sealed class TestAction : RAction { object Inc : TestAction() @@ -38,10 +36,10 @@ sealed class TestAction : RAction { fun testReducer(state: TestState, action: TestAction): TestState = when (action) { is TestAction.Inc -> { - state.copy(counter = state.counter + 1) + state.copy(counter = state.counter + 1, values = state.values + state.counter) } is TestAction.Dec -> { - state.copy(counter = state.counter - 1) + state.copy(counter = state.counter - 1, values = state.values + state.counter) } } @@ -50,20 +48,21 @@ class ReduxStoreSpec : SimpleSpec { @Test fun getState() { run { - val store = createReduxStore(::testReducer, TestState(10)) - assertEquals(TestState(10), store.getState()) + val store = createReduxStore(::testReducer, TestState(10, listOf())) + assertEquals(TestState(10, listOf()), store.getState()) } } @Test fun dispatch() { run { - val store = createReduxStore(::testReducer, TestState(10)) + val store = createReduxStore(::testReducer, TestState(10, listOf())) store.dispatch(TestAction.Inc) store.dispatch(TestAction.Inc) store.dispatch(TestAction.Inc) store.dispatch(TestAction.Dec) - assertEquals(TestState(12), store.getState()) + store.dispatch(TestAction.Dec) + assertEquals(TestState(11, listOf(10, 11, 12, 13, 12)), store.getState()) } } @@ -71,7 +70,7 @@ class ReduxStoreSpec : SimpleSpec { fun subscribe() { run { var counter = 0 - val store = createReduxStore(::testReducer, TestState(10)) + val store = createReduxStore(::testReducer, TestState(10, listOf())) store.subscribe { counter++ } diff --git a/kvision-modules/kvision-redux/src/test/kotlin/test/pl/treksoft/kvision/redux/StateBindingSpec.kt b/kvision-modules/kvision-redux/src/test/kotlin/test/pl/treksoft/kvision/redux/StateBindingSpec.kt index 5204402d..ec32d0d6 100644 --- a/kvision-modules/kvision-redux/src/test/kotlin/test/pl/treksoft/kvision/redux/StateBindingSpec.kt +++ b/kvision-modules/kvision-redux/src/test/kotlin/test/pl/treksoft/kvision/redux/StateBindingSpec.kt @@ -21,7 +21,6 @@ */ package test.pl.treksoft.kvision.redux -import kotlinx.serialization.Serializable import pl.treksoft.kvision.html.Div.Companion.div import pl.treksoft.kvision.panel.Root import pl.treksoft.kvision.panel.SimplePanel @@ -33,7 +32,6 @@ import test.pl.treksoft.kvision.DomSpec import kotlin.browser.document import kotlin.test.Test -@Serializable data class State(val counter: Int) sealed class StateAction : RAction { |