@@ -37,6 +37,84 @@ describe('markdown props', () => {
37
37
| \`hello\` | \`hello\` | This is a prop | \`boolean \\| string\` | \`false\` |
38
38
| \`hello\` | -- | This is a prop | \`boolean \\| string\` | \`false\` |
39
39
40
+ ` ) ;
41
+ } ) ;
42
+
43
+ it ( 'escapes template literal types' , ( ) => {
44
+ const markdown = propsToMarkdown ( [
45
+ {
46
+ name : 'width' ,
47
+ attr : 'width' ,
48
+ docs : 'Width of the button' ,
49
+ default : 'undefined' ,
50
+ type : '`${number}px` | `${number}%`' ,
51
+ mutable : false ,
52
+ optional : false ,
53
+ required : false ,
54
+ reflectToAttr : false ,
55
+ docsTags : [ ] ,
56
+ values : [ ] ,
57
+ } ,
58
+ ] ) . join ( '\n' ) ;
59
+
60
+ expect ( markdown ) . toEqual ( `## Properties
61
+
62
+ | Property | Attribute | Description | Type | Default |
63
+ | -------- | --------- | ------------------- | ----------------------------------- | ----------- |
64
+ | \`width\` | \`width\` | Width of the button | \`\` \`\${number}px\` \\| \`\${number}%\` \`\` | \`undefined\` |
65
+
66
+ ` ) ;
67
+ } ) ;
68
+
69
+ it ( 'escapes backticks in default value' , ( ) => {
70
+ const markdown = propsToMarkdown ( [
71
+ {
72
+ name : 'quote' ,
73
+ attr : 'quote' ,
74
+ docs : 'Quote character' ,
75
+ default : "'`'" ,
76
+ type : 'string' ,
77
+ mutable : false ,
78
+ optional : false ,
79
+ required : false ,
80
+ reflectToAttr : false ,
81
+ docsTags : [ ] ,
82
+ values : [ ] ,
83
+ } ,
84
+ ] ) . join ( '\n' ) ;
85
+
86
+ expect ( markdown ) . toEqual ( `## Properties
87
+
88
+ | Property | Attribute | Description | Type | Default |
89
+ | -------- | --------- | --------------- | -------- | --------- |
90
+ | \`quote\` | \`quote\` | Quote character | \`string\` | \`\` '\`' \`\` |
91
+
92
+ ` ) ;
93
+ } ) ;
94
+
95
+ it ( 'outputs `undefined` in default column when `prop.default` is undefined' , ( ) => {
96
+ const markdown = propsToMarkdown ( [
97
+ {
98
+ name : 'first' ,
99
+ attr : 'first' ,
100
+ docs : 'First name' ,
101
+ default : undefined ,
102
+ type : 'string' ,
103
+ mutable : false ,
104
+ optional : false ,
105
+ required : false ,
106
+ reflectToAttr : false ,
107
+ docsTags : [ ] ,
108
+ values : [ ] ,
109
+ } ,
110
+ ] ) . join ( '\n' ) ;
111
+
112
+ expect ( markdown ) . toBe ( `## Properties
113
+
114
+ | Property | Attribute | Description | Type | Default |
115
+ | -------- | --------- | ----------- | -------- | ----------- |
116
+ | \`first\` | \`first\` | First name | \`string\` | \`undefined\` |
117
+
40
118
` ) ;
41
119
} ) ;
42
120
} ) ;
0 commit comments