@@ -8,6 +8,8 @@ const deepIt = (ex, eq) => it(ex, () => assert[typeof eq === 'string' ? 'equal'
88const _deepIt = deepIt ;
99
1010/* Basic */
11+ it ( 'should throw without reviver' , ( ) => assert . throws ( hyperchain ) ) ;
12+ it ( 'should throw without component' , ( ) => assert . throws ( h ) ) ;
1113deepIt ( `h('div')` , {
1214 component : 'div' ,
1315 props : null ,
@@ -141,6 +143,11 @@ deepIt(`h.div({class: {object: true, class: false}})`, {
141143 props : { class : 'object' } ,
142144 children : [ ]
143145} ) ;
146+ deepIt ( `h.div({class: 'prop'})` , {
147+ component : 'div' ,
148+ props : { class : 'prop' } ,
149+ children : [ ]
150+ } ) ;
144151
145152describe ( 'separation' , ( ) => {
146153 const red = h . div . red ;
@@ -235,14 +242,16 @@ describe('opts.filterFalseyChildren', () => {
235242
236243
237244describe ( 'opts.elementMap' , ( ) => {
238- const h = hyperchain ( r , { elementMap : { div : 'p' } } ) ;
245+ const h = hyperchain ( r , { elementMap : { div : 'p' , null : null } } ) ;
239246 const deepIt = eval ( String ( _deepIt ) ) ;
240247
241248 deepIt ( `h.div()` , {
242249 component : 'p' ,
243250 props : null ,
244251 children : [ ]
245252 } ) ;
253+
254+ assert . throws ( ( ) => h . null ( ) ) ;
246255} ) ;
247256
248257describe ( 'opts.keyMap' , ( ) => {
@@ -254,6 +263,36 @@ describe('opts.keyMap', () => {
254263 props : { className : 'class' } ,
255264 children : [ ]
256265 } ) ;
266+ describe ( 'function' , ( ) => {
267+ const h = hyperchain ( r , {
268+ keyMap : {
269+ class : ( props , component , ...children ) => {
270+ if ( component !== 'fragment' ) {
271+ props . className = props . class ;
272+ }
273+ delete props . class ;
274+ }
275+ }
276+ } ) ;
277+ const deepIt = eval ( String ( _deepIt ) ) ;
278+
279+ deepIt ( `h.div.class()` , {
280+ component : 'div' ,
281+ props : { className : 'class' } ,
282+ children : [ ]
283+ } ) ;
284+ deepIt ( `h.fragment.class()` , {
285+ component : 'fragment' ,
286+ props : { } ,
287+ children : [ ]
288+ } ) ;
289+ } ) ;
290+ describe ( 'other' , ( ) => {
291+ const h = hyperchain ( r , { keyMap : { class : 1 } } ) ;
292+ const deepIt = eval ( String ( _deepIt ) ) ;
293+
294+ assert . throws ( ( ) => h . div . class ( ) ) ;
295+ } ) ;
257296} ) ;
258297
259298describe ( 'opts.style' , ( ) => {
@@ -265,6 +304,11 @@ describe('opts.style', () => {
265304 props : { class : 'hashed' } ,
266305 children : [ ]
267306 } ) ;
307+ deepIt ( `h.div.other()` , {
308+ component : 'div' ,
309+ props : { class : 'other' } ,
310+ children : [ ]
311+ } ) ;
268312} ) ;
269313
270314describe ( 'opts.stylePreserveNames' , ( ) => {
@@ -288,4 +332,8 @@ describe('text', () => {
288332 deepIt ( `h.div('a', 'b')` , '<div>ab</div>' ) ;
289333 deepIt ( `h.div(h.div('a'), 'b', h.div('c'))` , '<div><div>a</div>b<div>c</div></div>' ) ;
290334 deepIt ( `h.div({id:'app'})` , '<div id="app"></div>' ) ;
335+ deepIt ( `h.div({bool:false})` , '<div bool="false"></div>' ) ;
336+ deepIt ( `h.div({num:1})` , '<div num=1></div>' ) ;
337+ deepIt ( `h.div()` , '<div></div>' ) ;
338+ deepIt ( `h.div([['a']])` , '<div>a</div>' ) ;
291339} ) ;
0 commit comments