spec/redux_spec.rb in redux-0.1.0 vs spec/redux_spec.rb in redux-0.1.1

- old
+ new

@@ -53,7 +53,41 @@ store.dispatch "type" => "DECREMENT" assert_equal false, callback_called end end end + + describe ".combine_reducers" do + it "combines reducers" do + potato_reducer = ->(state = 0, action) { + case action['type'] + when "WORK" + state + 1 + else + state + end + } + + tomato_reducer = ->(state = 0, action) { + case action['type'] + when "WORK" + state - 1 + else + state + end + } + + root_reducer = Redux.combine_reducers({potato: potato_reducer, tomato: tomato_reducer}) + store = Redux::Store.new({}, &root_reducer) + store.dispatch "type" => "WORK" + + assert_equal( + { + potato: 1, + tomato: -1, + }, + store.state + ) + end + end end