@@ -63,13 +63,16 @@ const shouldNotStub = (type: ConcreteComponent) => doNotStubComponents.has(type)
63
63
export const addToDoNotStubComponents = ( type : ConcreteComponent ) =>
64
64
doNotStubComponents . add ( type )
65
65
66
- const stringifySymbols = ( props : ComponentPropsOptions ) => {
66
+ const normalizeStubProps = ( props : ComponentPropsOptions ) => {
67
67
// props are always normalized to object syntax
68
68
const $props = props as unknown as ComponentObjectPropsOptions
69
69
return Object . keys ( $props ) . reduce ( ( acc , key ) => {
70
70
if ( typeof $props [ key ] === 'symbol' ) {
71
71
return { ...acc , [ key ] : $props [ key ] ?. toString ( ) }
72
72
}
73
+ if ( typeof $props [ key ] === 'function' ) {
74
+ return { ...acc , [ key ] : '[Function]' }
75
+ }
73
76
return { ...acc , [ key ] : $props [ key ] }
74
77
} , { } )
75
78
}
@@ -100,13 +103,11 @@ export const createStub = ({
100
103
// causes an error.
101
104
// Only a problem when shallow mounting. For this reason we iterate of the
102
105
// props that will be passed and stringify any that are symbols.
103
- const propsWithoutSymbols = stringifySymbols ( props )
106
+ // Also having function text as attribute is useless and annoying so
107
+ // we replace it with "[Function]""
108
+ const stubProps = normalizeStubProps ( props )
104
109
105
- return h (
106
- tag ,
107
- propsWithoutSymbols ,
108
- renderStubDefaultSlot ? slots : undefined
109
- )
110
+ return h ( tag , stubProps , renderStubDefaultSlot ? slots : undefined )
110
111
}
111
112
}
112
113
} )
0 commit comments