def test_reducer_save_preset(): label = "Custom-1" state = {"colorbar": {"key": "value"}} action = presets.save_preset(label) state = presets.reducer(state, action) expect = {"labels": {0: label}} assert state["presets"] == expect
def test_reducer_save_preset_creates_presets_section(): label = "A" state = {"colorbar": {}} action = presets.save_preset(label) result = presets.reducer(state, action) uid = presets.Query(result).find_id(label) assert result["presets"]["labels"][uid] == label
def test_reducer_given_empty_state(): state = {} action = presets.save_preset("label") assert presets.reducer(state, action) == { "presets": { "labels": { 0: "label" } } }
def test_reducer_save_preset_adds_new_entry(): uid = 42 state = { "presets": { "labels": { uid: "A" }, } } action = presets.save_preset("B") result = presets.reducer(state, action) assert set(result["presets"]["labels"].values()) == {"A", "B"}
def test_reducer_save_new_preset(): label = "Custom-2" state = { "colorbar": { "key": "value" }, "presets": { "labels": { 0: "Custom-1" } }, } action = presets.save_preset("Custom-2") state = presets.reducer(state, action) result = state["presets"] expect = {"labels": {0: "Custom-1", 1: "Custom-2"}} assert expect == result
def test_reducer_update(): reducer = redux.combine_reducers(presets.reducer, colors.reducer) state = {} for action in [presets.save_preset("A"), presets.save_preset("A")]: state = reducer(state, action) assert set(state["presets"]["labels"].values()) == {"A"}