1
1
import * as path from 'path' ;
2
2
3
3
import { TSDocConfigFile } from '../TSDocConfigFile' ;
4
+ import { TSDocSynonymCollection } from '@microsoft/tsdoc/lib/configuration/TSDocSynonymCollection' ;
4
5
5
6
function getRelativePath ( testPath : string ) : string {
6
7
return path
@@ -23,10 +24,32 @@ expect.addSnapshotSerializer({
23
24
extendsPaths : value . extendsPaths ,
24
25
extendsFiles : value . extendsFiles ,
25
26
tagDefinitions : value . tagDefinitions ,
27
+ synonymAdditions : Array . from ( value . synonymAdditions ) . reduce < Record < string , ReadonlyArray < string > > > (
28
+ ( obj , [ key , value ] ) => {
29
+ obj [ key ] = value ;
30
+ return obj ;
31
+ } ,
32
+ { }
33
+ ) ,
34
+ synonymDeletions : Array . from ( value . synonymDeletions ) . reduce < Record < string , ReadonlyArray < string > > > (
35
+ ( obj , [ key , value ] ) => {
36
+ obj [ key ] = value ;
37
+ return obj ;
38
+ } ,
39
+ { }
40
+ ) ,
26
41
messages : value . log . messages
27
42
} ) ;
28
43
}
29
44
} ) ;
45
+ expect . addSnapshotSerializer ( {
46
+ test ( value : unknown ) {
47
+ return value instanceof TSDocSynonymCollection ;
48
+ } ,
49
+ print ( value : TSDocSynonymCollection , serialize : ( value : unknown ) => string , indent : ( str : string ) => string ) : string {
50
+ return serialize ( value . synonyms ) ;
51
+ }
52
+ } ) ;
30
53
31
54
function testLoadingFolder ( assetPath : string ) : TSDocConfigFile {
32
55
return TSDocConfigFile . loadForFolder ( path . join ( __dirname , assetPath ) ) ;
@@ -40,6 +63,8 @@ test('Load p1', () => {
40
63
"fileNotFound": false,
41
64
"filePath": "assets/p1/tsdoc.json",
42
65
"messages": Array [],
66
+ "synonymAdditions": Object {},
67
+ "synonymDeletions": Object {},
43
68
"tagDefinitions": Array [],
44
69
"tsdocSchema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
45
70
}
@@ -66,6 +91,8 @@ test('Load p2', () => {
66
91
"unformattedText": "File not found",
67
92
},
68
93
],
94
+ "synonymAdditions": Object {},
95
+ "synonymDeletions": Object {},
69
96
"tagDefinitions": Array [],
70
97
"tsdocSchema": "",
71
98
}
@@ -81,8 +108,11 @@ test('Load p3', () => {
81
108
"fileNotFound": false,
82
109
"filePath": "assets/p3/base1/tsdoc-base1.json",
83
110
"messages": Array [],
111
+ "synonymAdditions": Object {},
112
+ "synonymDeletions": Object {},
84
113
"tagDefinitions": Array [
85
114
TSDocTagDefinition {
115
+ "_synonymCollection": Array [],
86
116
"allowMultiple": false,
87
117
"standardization": "None",
88
118
"syntaxKind": 2,
@@ -98,8 +128,11 @@ test('Load p3', () => {
98
128
"fileNotFound": false,
99
129
"filePath": "assets/p3/base2/tsdoc-base2.json",
100
130
"messages": Array [],
131
+ "synonymAdditions": Object {},
132
+ "synonymDeletions": Object {},
101
133
"tagDefinitions": Array [
102
134
TSDocTagDefinition {
135
+ "_synonymCollection": Array [],
103
136
"allowMultiple": false,
104
137
"standardization": "None",
105
138
"syntaxKind": 2,
@@ -117,8 +150,11 @@ test('Load p3', () => {
117
150
"fileNotFound": false,
118
151
"filePath": "assets/p3/tsdoc.json",
119
152
"messages": Array [],
153
+ "synonymAdditions": Object {},
154
+ "synonymDeletions": Object {},
120
155
"tagDefinitions": Array [
121
156
TSDocTagDefinition {
157
+ "_synonymCollection": Array [],
122
158
"allowMultiple": false,
123
159
"standardization": "None",
124
160
"syntaxKind": 2,
@@ -140,8 +176,11 @@ test('Load p4', () => {
140
176
"fileNotFound": false,
141
177
"filePath": "assets/p4/node_modules/example-lib/dist/tsdoc-example.json",
142
178
"messages": Array [],
179
+ "synonymAdditions": Object {},
180
+ "synonymDeletions": Object {},
143
181
"tagDefinitions": Array [
144
182
TSDocTagDefinition {
183
+ "_synonymCollection": Array [],
145
184
"allowMultiple": false,
146
185
"standardization": "None",
147
186
"syntaxKind": 2,
@@ -158,8 +197,11 @@ test('Load p4', () => {
158
197
"fileNotFound": false,
159
198
"filePath": "assets/p4/tsdoc.json",
160
199
"messages": Array [],
200
+ "synonymAdditions": Object {},
201
+ "synonymDeletions": Object {},
161
202
"tagDefinitions": Array [
162
203
TSDocTagDefinition {
204
+ "_synonymCollection": Array [],
163
205
"allowMultiple": false,
164
206
"standardization": "None",
165
207
"syntaxKind": 2,
@@ -171,3 +213,33 @@ test('Load p4', () => {
171
213
}
172
214
` ) ;
173
215
} ) ;
216
+ test ( 'Load synonyms' , ( ) => {
217
+ expect ( testLoadingFolder ( 'assets/synonyms' ) ) . toMatchInlineSnapshot ( `
218
+ Object {
219
+ "extendsFiles": Array [],
220
+ "extendsPaths": Array [],
221
+ "fileNotFound": false,
222
+ "filePath": "assets/synonyms/tsdoc.json",
223
+ "messages": Array [],
224
+ "synonymAdditions": Object {
225
+ "@readonly": Array [
226
+ "@readonly2",
227
+ ],
228
+ },
229
+ "synonymDeletions": Object {},
230
+ "tagDefinitions": Array [
231
+ TSDocTagDefinition {
232
+ "_synonymCollection": Array [
233
+ "@bar",
234
+ ],
235
+ "allowMultiple": false,
236
+ "standardization": "None",
237
+ "syntaxKind": 1,
238
+ "tagName": "@foo",
239
+ "tagNameWithUpperCase": "@FOO",
240
+ },
241
+ ],
242
+ "tsdocSchema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
243
+ }
244
+ ` ) ;
245
+ } ) ;
0 commit comments