示例#1
0
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
示例#2
0
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
示例#3
0
def test_reducer_given_empty_state():
    state = {}
    action = presets.save_preset("label")
    assert presets.reducer(state, action) == {
        "presets": {
            "labels": {
                0: "label"
            }
        }
    }
示例#4
0
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"}
示例#5
0
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
示例#6
0
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"}