@@ -43,21 +43,49 @@ describeWithDOM(`Given the ComponentQueries library`, () => {
4343 let receivedProps ;
4444
4545 const ComponentQueriedComponent = ComponentQueries (
46- ( width ) => width <= 100 ? { foo : `bar` } : { } ,
47- ( width ) => width > 100 && width <= 500 ? { bob : `baz` } : { }
46+ ( { width } ) => width <= 100 ? { foo : `bar` } : { } ,
47+ ( { width } ) => width > 100 && width <= 500 ? { bob : `baz` } : { } ,
48+ ( { height } ) => height <= 100 ? { zip : `zap` } : { }
4849 ) ( ( props ) => { receivedProps = props ; return < div > </ div > ; } ) ;
4950
5051 // Initial render
5152 const mounted = mount ( < ComponentQueriedComponent size = { { width : 100 , height : 100 } } /> ) ;
52- expect ( receivedProps ) . to . eql ( { foo : `bar` } ) ;
53+ expect ( receivedProps ) . to . eql ( { foo : `bar` , zip : `zap` } ) ;
5354
5455 // Update size, but no size change
5556 mounted . setProps ( { size : { width : 100 , height : 100 } } ) ;
56- expect ( receivedProps ) . to . eql ( { foo : `bar` } ) ;
57+ expect ( receivedProps ) . to . eql ( { foo : `bar` , zip : `zap` } ) ;
5758
5859 // Update size, with change.
59- mounted . setProps ( { size : { width : 101 , height : 100 } } ) ;
60+ mounted . setProps ( { size : { width : 101 , height : 99 } } ) ;
61+ expect ( receivedProps ) . to . eql ( { bob : `baz` , zip : `zap` } ) ;
62+
63+ // Update size, with change.
64+ mounted . setProps ( { size : { width : 101 , height : 101 } } ) ;
6065 expect ( receivedProps ) . to . eql ( { bob : `baz` } ) ;
6166 } ) ;
67+
68+ it ( `Then it should throw an error when a duplicate prop is provided` , ( ) => {
69+ const ComponentQueriedComponent = ComponentQueries (
70+ ( { width } ) => width <= 100 ? { foo : `bar` } : { }
71+ ) ( ( ) => < div > </ div > ) ;
72+
73+ // Initial render duplicate prop
74+ const onMount = ( ) => mount (
75+ < ComponentQueriedComponent foo = "foo" size = { { width : 100 , height : 100 } } />
76+ ) ;
77+
78+ expect ( onMount ) . to . throw ( / D u p l i c a t e p r o p h a s b e e n p r o v i d e d / ) ;
79+
80+ // Updated component duplicate prop
81+ const mounted = mount (
82+ < ComponentQueriedComponent size = { { width : 100 , height : 100 } } />
83+ ) ;
84+
85+ const updateComponent = ( ) =>
86+ mounted . setProps ( { foo : `baz` } ) ;
87+
88+ expect ( updateComponent ) . to . throw ( / D u p l i c a t e p r o p h a s b e e n p r o v i d e d / ) ;
89+ } ) ;
6290 } ) ;
6391} ) ;
0 commit comments