コード例 #1
0
 def test_throws_for_a_primative_action_creator(self):
     with self.assertRaises(Exception) as e:
         bind_action_creators('string', self.store['dispatch'])
     self.assertTrue(
         re.search(
             'bind_action_creators expected an object or a function, instead received <class \'str\'>',
             str(e.exception)))
コード例 #2
0
 def test_throws_for_undefined_action_creator(self):
     with self.assertRaises(Exception) as e:
         bind_action_creators(None, self.store['dispatch'])
     self.assertTrue(
         re.search(
             r'bind_action_creators expected an object or a function, instead received None',
             str(e.exception)))
コード例 #3
0
	def test_supports_wrapping_single_function_only(self):
		action_creator = action_creators['add_todo']
		bound_action_creator = bind_action_creators(action_creator, self.store['dispatch'])
		
		action = bound_action_creator('Hello')
		self.assertEqual(action, action_creator('Hello'))
		self.assertEqual(self.store['get_state'](), [dict(id=1, text='Hello')])
コード例 #4
0
    def test_skips_non_function_values_in_the_passed_object(self):
        bound_action_creators = bind_action_creators(
            dict(foo=42, bar='baz', wow=None, much={}, **action_creators),
            self.store['dispatch'])

        self.assertEqual(bound_action_creators.keys(),
                         self.action_creator_functions.keys())
コード例 #5
0
	def test_wraps_action_creators_with_dispatch_function(self):
		bound_action_creators = bind_action_creators(action_creators, self.store['dispatch'])
		self.assertEqual(bound_action_creators.keys(), self.action_creator_functions.keys())
	
		action = bound_action_creators['add_todo']('Hello')
		self.assertEqual(action, action_creators['add_todo']('Hello'))
		
		self.assertEqual(self.store['get_state'](), [dict(id=1, text='Hello')])
コード例 #6
0
    def test_supports_wrapping_single_function_only(self):
        action_creator = action_creators['add_todo']
        bound_action_creator = bind_action_creators(action_creator,
                                                    self.store['dispatch'])

        action = bound_action_creator('Hello')
        self.assertEqual(action, action_creator('Hello'))
        self.assertEqual(self.store['get_state'](), [dict(id=1, text='Hello')])
コード例 #7
0
	def test_skips_non_function_values_in_the_passed_object(self):
		bound_action_creators = bind_action_creators(dict(
			foo=42,
			bar='baz',
			wow=None,
			much={},
			**action_creators
		), self.store['dispatch'])
		
		self.assertEqual(bound_action_creators.keys(), self.action_creator_functions.keys())
コード例 #8
0
    def test_wraps_action_creators_with_dispatch_function(self):
        bound_action_creators = bind_action_creators(action_creators,
                                                     self.store['dispatch'])
        self.assertEqual(bound_action_creators.keys(),
                         self.action_creator_functions.keys())

        action = bound_action_creators['add_todo']('Hello')
        self.assertEqual(action, action_creators['add_todo']('Hello'))

        self.assertEqual(self.store['get_state'](), [dict(id=1, text='Hello')])
コード例 #9
0
	def test_throws_for_a_primative_action_creator(self):
		with self.assertRaises(Exception) as e:
			bind_action_creators('string', self.store['dispatch'])
		self.assertTrue(re.search('bind_action_creators expected an object or a function, instead received <class \'str\'>', str(e.exception)))
コード例 #10
0
	def test_throws_for_undefined_action_creator(self):
		with self.assertRaises(Exception) as e:
			bind_action_creators(None, self.store['dispatch'])
		self.assertTrue(re.search(r'bind_action_creators expected an object or a function, instead received None', str(e.exception)))