11import * as path from 'path' ;
22
33import { TSDocConfigFile } from '../TSDocConfigFile' ;
4+ import { TSDocSynonymCollection } from '@microsoft/tsdoc/lib/configuration/TSDocSynonymCollection' ;
45
56function getRelativePath ( testPath : string ) : string {
67 return path
@@ -23,10 +24,32 @@ expect.addSnapshotSerializer({
2324 extendsPaths : value . extendsPaths ,
2425 extendsFiles : value . extendsFiles ,
2526 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+ ) ,
2641 messages : value . log . messages
2742 } ) ;
2843 }
2944} ) ;
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+ } ) ;
3053
3154function testLoadingFolder ( assetPath : string ) : TSDocConfigFile {
3255 return TSDocConfigFile . loadForFolder ( path . join ( __dirname , assetPath ) ) ;
@@ -40,6 +63,8 @@ test('Load p1', () => {
4063 "fileNotFound": false,
4164 "filePath": "assets/p1/tsdoc.json",
4265 "messages": Array [],
66+ "synonymAdditions": Object {},
67+ "synonymDeletions": Object {},
4368 "tagDefinitions": Array [],
4469 "tsdocSchema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
4570 }
@@ -66,6 +91,8 @@ test('Load p2', () => {
6691 "unformattedText": "File not found",
6792 },
6893 ],
94+ "synonymAdditions": Object {},
95+ "synonymDeletions": Object {},
6996 "tagDefinitions": Array [],
7097 "tsdocSchema": "",
7198 }
@@ -81,8 +108,11 @@ test('Load p3', () => {
81108 "fileNotFound": false,
82109 "filePath": "assets/p3/base1/tsdoc-base1.json",
83110 "messages": Array [],
111+ "synonymAdditions": Object {},
112+ "synonymDeletions": Object {},
84113 "tagDefinitions": Array [
85114 TSDocTagDefinition {
115+ "_synonymCollection": Array [],
86116 "allowMultiple": false,
87117 "standardization": "None",
88118 "syntaxKind": 2,
@@ -98,8 +128,11 @@ test('Load p3', () => {
98128 "fileNotFound": false,
99129 "filePath": "assets/p3/base2/tsdoc-base2.json",
100130 "messages": Array [],
131+ "synonymAdditions": Object {},
132+ "synonymDeletions": Object {},
101133 "tagDefinitions": Array [
102134 TSDocTagDefinition {
135+ "_synonymCollection": Array [],
103136 "allowMultiple": false,
104137 "standardization": "None",
105138 "syntaxKind": 2,
@@ -117,8 +150,11 @@ test('Load p3', () => {
117150 "fileNotFound": false,
118151 "filePath": "assets/p3/tsdoc.json",
119152 "messages": Array [],
153+ "synonymAdditions": Object {},
154+ "synonymDeletions": Object {},
120155 "tagDefinitions": Array [
121156 TSDocTagDefinition {
157+ "_synonymCollection": Array [],
122158 "allowMultiple": false,
123159 "standardization": "None",
124160 "syntaxKind": 2,
@@ -140,8 +176,11 @@ test('Load p4', () => {
140176 "fileNotFound": false,
141177 "filePath": "assets/p4/node_modules/example-lib/dist/tsdoc-example.json",
142178 "messages": Array [],
179+ "synonymAdditions": Object {},
180+ "synonymDeletions": Object {},
143181 "tagDefinitions": Array [
144182 TSDocTagDefinition {
183+ "_synonymCollection": Array [],
145184 "allowMultiple": false,
146185 "standardization": "None",
147186 "syntaxKind": 2,
@@ -158,8 +197,11 @@ test('Load p4', () => {
158197 "fileNotFound": false,
159198 "filePath": "assets/p4/tsdoc.json",
160199 "messages": Array [],
200+ "synonymAdditions": Object {},
201+ "synonymDeletions": Object {},
161202 "tagDefinitions": Array [
162203 TSDocTagDefinition {
204+ "_synonymCollection": Array [],
163205 "allowMultiple": false,
164206 "standardization": "None",
165207 "syntaxKind": 2,
@@ -171,3 +213,33 @@ test('Load p4', () => {
171213 }
172214 ` ) ;
173215} ) ;
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