示例#1
0
    def test_act__state_changed__subscriber_triggered(self):
        expected = {'some': 'object'}
        target = Store(test_state)
        subscriber = Mock()
        target.subscribe(subscriber)
        test_action = Action()
        test_action.act = Mock(return_value=expected)

        target.act(test_action)

        subscriber.assert_called_once()
示例#2
0
    def test_act__action_gets_state(self):
        target = Store(test_state)

        test_action = Action()

        def assertion(state):
            assert test_state == state
            return state

        test_action.act = assertion

        target.act(test_action)
示例#3
0
    def test_act__one_middleware__middleware_is_called(self):
        sideeffect = Mock()

        def middleware(next):
            def apply(action):
                sideeffect()
                next(action)

            return apply

        target = Store(test_state, [middleware])
        test_action = Action()

        target.act(test_action)

        sideeffect.assert_called_once()
示例#4
0
    def test_act__returns_a_copy(self):
        target = Action()

        actual = target.act(test_state)

        assert test_state == actual
示例#5
0
    def test_act__returns_another_object(self):
        target = Action()

        actual = target.act(test_state)

        assert not test_state is actual