@@ -16,57 +16,42 @@ describe('Module: RenderSnippetHoverProvider', async () => {
16
16
name : 'title' ,
17
17
description : 'The title of the product' ,
18
18
type : 'string' ,
19
+ required : true ,
19
20
} ,
20
21
{
21
22
name : 'border-radius' ,
22
23
description : 'The border radius in px' ,
23
24
type : 'number' ,
25
+ required : false ,
24
26
} ,
25
27
{
26
28
name : 'no-type' ,
27
29
description : 'This parameter has no type' ,
28
30
type : null ,
31
+ required : true ,
29
32
} ,
30
33
{
31
34
name : 'no-description' ,
32
35
description : null ,
33
36
type : 'string' ,
37
+ required : true ,
34
38
} ,
35
39
{
36
40
name : 'no-type-or-description' ,
37
41
description : null ,
38
42
type : null ,
43
+ required : true ,
39
44
} ,
40
45
] ,
41
46
} ,
42
47
} ;
43
48
44
- const createProvider = ( getSnippetDefinition : GetSnippetDefinitionForURI ) => {
45
- return new HoverProvider (
46
- new DocumentManager ( ) ,
47
- {
48
- filters : async ( ) => [ ] ,
49
- objects : async ( ) => [ ] ,
50
- tags : async ( ) => [ ] ,
51
- systemTranslations : async ( ) => ( { } ) ,
52
- } ,
53
- async ( _rootUri : string ) => ( { } as MetafieldDefinitionMap ) ,
54
- async ( ) => ( { } ) ,
55
- async ( ) => [ ] ,
56
- getSnippetDefinition ,
57
- ) ;
58
- } ;
59
-
60
- beforeEach ( async ( ) => {
61
- getSnippetDefinition = async ( ) => mockSnippetDefinition ;
62
- provider = createProvider ( getSnippetDefinition ) ;
63
- } ) ;
64
-
65
49
describe ( 'hover' , ( ) => {
66
50
it ( 'should return snippet definition with all parameters' , async ( ) => {
51
+ provider = createProvider ( async ( ) => mockSnippetDefinition ) ;
67
52
await expect ( provider ) . to . hover (
68
53
`{% render 'product-car█d' %}` ,
69
- '### product-card\n\n**Parameters:**\n- `title`: string - The title of the product\n- `border-radius`: number - The border radius in px\n- `no-type` - This parameter has no type\n- `no-description`: string\n- `no-type-or-description`' ,
54
+ '### product-card\n\n**Parameters:**\n- `title`: string - The title of the product\n- `border-radius` (Optional) : number - The border radius in px\n- `no-type` - This parameter has no type\n- `no-description`: string\n- `no-type-or-description`' ,
70
55
) ;
71
56
} ) ;
72
57
@@ -86,5 +71,47 @@ describe('Module: RenderSnippetHoverProvider', async () => {
86
71
await expect ( provider ) . to . hover ( `{% assign asdf = 'snip█pet' %}` , null ) ;
87
72
await expect ( provider ) . to . hover ( `{{ 'snip█pet' }}` , null ) ;
88
73
} ) ;
74
+
75
+ it ( 'should wrap optional parameters in []' , async ( ) => {
76
+ provider = createProvider ( async ( ) => ( {
77
+ name : 'product-card' ,
78
+ liquidDoc : {
79
+ parameters : [
80
+ {
81
+ name : 'title' ,
82
+ description : 'The title of the product' ,
83
+ type : 'string' ,
84
+ required : true ,
85
+ } ,
86
+ {
87
+ name : 'border-radius' ,
88
+ description : 'The border radius in px' ,
89
+ type : 'number' ,
90
+ required : false ,
91
+ } ,
92
+ ] ,
93
+ } ,
94
+ } ) ) ;
95
+ await expect ( provider ) . to . hover (
96
+ `{% render 'product-car█d' %}` ,
97
+ '### product-card\n\n**Parameters:**\n- `title`: string - The title of the product\n- `border-radius` (Optional): number - The border radius in px' ,
98
+ ) ;
99
+ } ) ;
89
100
} ) ;
90
101
} ) ;
102
+
103
+ const createProvider = ( getSnippetDefinition : GetSnippetDefinitionForURI ) => {
104
+ return new HoverProvider (
105
+ new DocumentManager ( ) ,
106
+ {
107
+ filters : async ( ) => [ ] ,
108
+ objects : async ( ) => [ ] ,
109
+ tags : async ( ) => [ ] ,
110
+ systemTranslations : async ( ) => ( { } ) ,
111
+ } ,
112
+ async ( _rootUri : string ) => ( { } as MetafieldDefinitionMap ) ,
113
+ async ( ) => ( { } ) ,
114
+ async ( ) => [ ] ,
115
+ getSnippetDefinition ,
116
+ ) ;
117
+ } ;
0 commit comments