From 0b349de3cc699b54b02d7177418c8cf155afe929 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Sun, 3 May 2020 22:43:53 +0200 Subject: Simplify state binding functions. Deprecate stateBinding() in favor of bind(). --- .../pl/treksoft/kvision/redux/StateBindingSpec.kt | 38 +++------------------- 1 file changed, 4 insertions(+), 34 deletions(-) (limited to 'kvision-modules/kvision-redux/src/test/kotlin') 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 dea28ade..b4415fcb 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 @@ -25,8 +25,7 @@ import pl.treksoft.kvision.html.div import pl.treksoft.kvision.panel.Root import pl.treksoft.kvision.panel.SimplePanel import pl.treksoft.kvision.redux.createReduxStore -import pl.treksoft.kvision.state.stateBinding -import pl.treksoft.kvision.state.stateUpdate +import pl.treksoft.kvision.state.bind import redux.RAction import test.pl.treksoft.kvision.DomSpec import kotlin.browser.document @@ -57,51 +56,22 @@ class StateBindingSpec : DomSpec { val store = createReduxStore(::stateReducer, State(10)) val container = SimplePanel() - container.stateBinding(store) { state -> + container.bind(store) { state -> div("${state.counter}") } root.add(container) val element = document.getElementById("test") assertEqualsHtml( - "
10
", + "
10
", element?.innerHTML, "Should render initial state of the container" ) store.dispatch(StateAction.Inc) assertEqualsHtml( - "
11
", + "
11
", element?.innerHTML, "Should render changed state of the container" ) } } - - @Test - fun stateUpdate() { - run { - val root = Root("test", fixed = true) - val store = createReduxStore(::stateReducer, State(10)) - - val container = SimplePanel() - container.stateUpdate(store) { state -> - div("${state.counter}") - } updateWith { state, d -> - d.content = "${state.counter}" - } - root.add(container) - val element = document.getElementById("test") - assertEqualsHtml( - "
10
", - element?.innerHTML, - "Should render initial state of the container" - ) - store.dispatch(StateAction.Inc) - assertEqualsHtml( - "
11
", - element?.innerHTML, - "Should render changed state of the container" - ) - } - } - } -- cgit