11import  {  expect ,  describe ,  it  }  from  'vitest' 
22import  {  mount  }  from  '@vue/test-utils' 
3+ import  {  defineAsyncComponent ,  defineComponent ,  h ,  markRaw  }  from  'vue' 
34import  SanityContent  from  '../../src/runtime/components/sanity-content' 
45
56import  *  as  exampleBlocks  from  './fixture/portable-text' 
67
8+ const  CustomBlockComponent  =  defineComponent ( { 
9+   props : {  exampleProp : String  } , 
10+   setup : ( props ,  {  slots } )  =>  ( )  =>  h ( 'div' ,  { } ,  { 
11+     default : ( )  =>  [ 
12+       props . exampleProp , 
13+       slots . default ?.( ) , 
14+     ] , 
15+   } ) , 
16+ } ) 
17+ 
718describe ( 'SanityContent' ,  ( )  =>  { 
819  it ( 'should render with no props' ,  ( )  =>  { 
920    const  wrapper  =  mount ( SanityContent ) 
@@ -15,9 +26,20 @@ describe('SanityContent', () => {
1526      const  wrapper  =  mount ( SanityContent  as  any ,  { 
1627        props : { 
1728          blocks : Array . isArray ( block )  ? block  : [ block ] , 
18-           serializers : { 
19-             types : {  customIcon : 'i'  } , 
20-           } , 
29+           serializers : markRaw ( { 
30+             types : { 
31+               customIcon : 'i' , 
32+               // This is how to access a component registered by `@nuxt/components` 
33+               customComponent1 : CustomBlockComponent , 
34+               // A directly imported component 
35+               customComponent2 : CustomBlockComponent , 
36+               // Example of a more complex async component 
37+               customComponent3 : defineAsyncComponent ( { 
38+                 loadingComponent : ( )  =>  h ( 'div' ,  'Loading...' ) , 
39+                 loader : ( )  =>  Promise . resolve ( CustomBlockComponent ) , 
40+               } ) , 
41+             } , 
42+           } ) , 
2143        } , 
2244      } ) 
2345      expect ( wrapper . html ( ) ) . toMatchSnapshot ( ) 
0 commit comments