@@ -21,8 +21,8 @@ describe("generateTS function", () => {
2121 } ) ;
2222
2323 expect ( generatedTS ) . toEqual ( expect . stringContaining ( "interface" ) ) ; // Check for Output is not undefined
24- expect ( generatedTS ) . toEqual ( expect . stringContaining ( "Dishes " ) ) ; // Check for whether typeDef of Content type is included
25- expect ( generatedTS ) . toMatch ( / \/ \* \* [ \s \S ] * ? \* \/ \s * ( e x p o r t ) / ) ; // Check for Documentation Generated with export
24+ expect ( generatedTS ) . toEqual ( expect . stringContaining ( "Testimport " ) ) ; // Check for whether typeDef of Content type is included
25+ expect ( generatedTS ) . toMatch ( / \/ \* \* \s * \w + \s * \* \/ / ) ; // Check for field-level Documentation is generated
2626 } ) ;
2727
2828 it ( "generates type definitions without Documentation" , async ( ) => {
@@ -43,7 +43,7 @@ describe("generateTS function", () => {
4343 } ) ;
4444
4545 expect ( generatedTS ) . toEqual ( expect . stringContaining ( "interface" ) ) ; // Check for Output is not undefined
46- expect ( generatedTS ) . toEqual ( expect . stringContaining ( "Dishes " ) ) ; // Check for whether typeDef of Content type is included
46+ expect ( generatedTS ) . toEqual ( expect . stringContaining ( "Testimport " ) ) ; // Check for whether typeDef of Content type is included
4747 expect ( generatedTS ) . not . toMatch ( / \/ \* \* .* \* \/ \n \s * ( e x p o r t ) / ) ; // Check for No Documentation is generated
4848 } ) ;
4949
@@ -65,8 +65,8 @@ describe("generateTS function", () => {
6565 } ) ;
6666
6767 expect ( generatedTS ) . toEqual ( expect . stringContaining ( "interface" ) ) ; // Check for Output is not undefined
68- expect ( generatedTS ) . toMatch ( / (? ! D i s h e s ) t e s t D i s h e s / ) ; // Check for whether typeDef of Content type is included with test prefix
69- expect ( generatedTS ) . toMatch ( / \/ \* \* . * \* \/ \n \s * ( e x p o r t ) / ) ; // Check for Documentation is generated
68+ expect ( generatedTS ) . toMatch ( / (? ! T e s t i m p o r t ) t e s t T e s t i m p o r t / ) ; // Check for whether typeDef of Content type is included with test prefix
69+ expect ( generatedTS ) . toMatch ( / \/ \* \* \s * \w + \s * \* \/ / ) ; // Check for field-level Documentation is generated
7070 } ) ;
7171
7272 it ( "generates type definitions with system fields" , async ( ) => {
@@ -87,10 +87,10 @@ describe("generateTS function", () => {
8787 } ) ;
8888
8989 expect ( generatedTS ) . toEqual ( expect . stringContaining ( "interface" ) ) ; // Check for Output is not undefined
90- expect ( generatedTS ) . toMatch ( / D i s h e s / ) ; // Check for whether typeDef of Content type is included
90+ expect ( generatedTS ) . toMatch ( / T e s t i m p o r t / ) ; // Check for whether typeDef of Content type is included
9191 expect ( generatedTS ) . toMatch ( / e x p o r t i n t e r f a c e S y s t e m F i e l d s \{ \n / ) ; // Check for whether System Fields are Created
9292 expect ( generatedTS ) . toMatch ( / e x t e n d s S y s t e m F i e l d s \{ \n / ) ; // Check for whether interfaces have extended system fields interface
93- expect ( generatedTS ) . toMatch ( / \/ \* \* . * \* \/ \n \s * ( e x p o r t ) / ) ; // Check for Documentation is generated
93+ expect ( generatedTS ) . toMatch ( / \/ \* \* \s * \w + \s * \* \/ / ) ; // Check for field-level Documentation is generated
9494 } ) ;
9595
9696 it ( "generates type definitions with editable fields" , async ( ) => {
@@ -111,12 +111,12 @@ describe("generateTS function", () => {
111111 } ) ;
112112
113113 expect ( generatedTS ) . toEqual ( expect . stringContaining ( "interface" ) ) ; // Check for Output is not undefined
114- expect ( generatedTS ) . toMatch ( / D i s h e s / ) ; // Check for whether typeDef of Content type is included
114+ expect ( generatedTS ) . toMatch ( / T e s t i m p o r t / ) ; // Check for whether typeDef of Content type is included
115115 expect ( generatedTS ) . toMatch ( / e x p o r t i n t e r f a c e C S L P A t t r i b u t e / ) ; // Check for whether CSLP attribute interface is created
116116 expect ( generatedTS ) . toMatch ( / e x p o r t t y p e C S L P F i e l d M a p p i n g / ) ; // Check for whether CSLP field mapping type is created
117117 expect ( generatedTS ) . toMatch ( / \$ \? \: / ) ; // Check for editable field mappings with $ property
118118 expect ( generatedTS ) . toMatch ( / \? \: C S L P F i e l d M a p p i n g / ) ; // Check for individual field CSLP mappings
119- expect ( generatedTS ) . toMatch ( / \/ \* \* . * \* \/ \n \s * ( e x p o r t ) / ) ; // Check for Documentation is generated
119+ expect ( generatedTS ) . toMatch ( / \/ \* \* \s * \w + \s * \* \/ / ) ; // Check for field-level Documentation is generated
120120 } ) ;
121121
122122 it ( "generates type definitions with ReferencedEntry enabled" , async ( ) => {
@@ -136,10 +136,10 @@ describe("generateTS function", () => {
136136 includeReferencedEntry,
137137 } ) ;
138138
139- expect ( generatedTS ) . toEqual ( expect . stringContaining ( "interface" ) ) ; // Check for Output is not undefined
140- expect ( generatedTS ) . toEqual ( expect . stringContaining ( "Dishes " ) ) ; // Check for whether typeDef of Content type is included
139+ expect ( generatedTS ) . toEqual ( expect . stringContaining ( "interface" ) ) ; // Check for whether typeDef of Content type is included
140+ expect ( generatedTS ) . toEqual ( expect . stringContaining ( "Testimport " ) ) ; // Check for whether typeDef of Content type is included
141141 expect ( generatedTS ) . toMatch ( / R e f e r e n c e d E n t r y / ) ; // Check that ReferencedEntry interface is included
142- expect ( generatedTS ) . toMatch ( / \/ \* \* . * \* \/ \n \s * ( e x p o r t ) / ) ; // Check for Documentation is generated
142+ expect ( generatedTS ) . toMatch ( / \/ \* \* \s * \w + \s * \* \/ / ) ; // Check for field-level Documentation is generated
143143 } ) ;
144144
145145 it ( "generates type definitions without ReferencedEntry (default)" , async ( ) => {
@@ -159,9 +159,9 @@ describe("generateTS function", () => {
159159 } ) ;
160160
161161 expect ( generatedTS ) . toEqual ( expect . stringContaining ( "interface" ) ) ; // Check for Output is not undefined
162- expect ( generatedTS ) . toEqual ( expect . stringContaining ( "Dishes " ) ) ; // Check for whether typeDef of Content type is included
162+ expect ( generatedTS ) . toEqual ( expect . stringContaining ( "Testimport " ) ) ; // Check for whether typeDef of Content type is included
163163 expect ( generatedTS ) . not . toMatch ( / R e f e r e n c e d E n t r y / ) ; // Check that ReferencedEntry interface is not included
164- expect ( generatedTS ) . toMatch ( / \/ \* \* . * \* \/ \n \s * ( e x p o r t ) / ) ; // Check for Documentation is generated
164+ expect ( generatedTS ) . toMatch ( / \/ \* \* \s * \w + \s * \* \/ / ) ; // Check for field-level Documentation is generated
165165 } ) ;
166166} ) ;
167167
@@ -246,20 +246,16 @@ describe("generateTS function with errors", () => {
246246 const tokenType = process . env . TOKENTYPE as unknown as any ;
247247 const branch = process . env . BRANCH as unknown as any ;
248248
249- try {
250- await generateTS ( {
249+ await expect (
250+ generateTS ( {
251251 token,
252252 apiKey,
253253 environment,
254254 region,
255255 tokenType,
256256 branch,
257- } ) ;
258- } catch ( err : any ) {
259- expect ( err . error_message ) . toEqual (
260- "Invalid Credentials: Please check the provided apiKey, token and region."
261- ) ;
262- }
257+ } )
258+ ) . rejects . toThrow ( ) ;
263259 } ) ;
264260
265261 it ( "Check for invalid delivery token" , async ( ) => {
@@ -270,18 +266,16 @@ describe("generateTS function with errors", () => {
270266 const tokenType = process . env . TOKENTYPE as unknown as any ;
271267 const branch = process . env . BRANCH as unknown as any ;
272268
273- try {
274- await generateTS ( {
269+ await expect (
270+ generateTS ( {
275271 token,
276272 apiKey,
277273 environment,
278274 region,
279275 tokenType,
280276 branch,
281- } ) ;
282- } catch ( err : any ) {
283- expect ( err . error_message ) . toEqual ( "Something went wrong, Bad Request" ) ;
284- }
277+ } )
278+ ) . rejects . toThrow ( ) ;
285279 } ) ;
286280
287281 it ( "Check for default error with invalid branch" , async ( ) => {
@@ -292,20 +286,16 @@ describe("generateTS function with errors", () => {
292286 const tokenType = process . env . TOKENTYPE as unknown as any ;
293287 const branch = "mai" as unknown as any ;
294288
295- try {
296- await generateTS ( {
289+ await expect (
290+ generateTS ( {
297291 token,
298292 apiKey,
299293 environment,
300294 region,
301295 tokenType,
302296 branch,
303- } ) ;
304- } catch ( err : any ) {
305- expect ( err . error_message ) . toEqual (
306- "Something went wrong, Access denied. You have insufficient permissions to perform operation on this branch 'mai'."
307- ) ;
308- }
297+ } )
298+ ) . rejects . toThrow ( ) ;
309299 } ) ;
310300
311301 it ( "Check for default error like Bad-Request" , async ( ) => {
@@ -316,17 +306,15 @@ describe("generateTS function with errors", () => {
316306 const tokenType = process . env . TOKENTYPE as unknown as any ;
317307 const branch = process . env . BRANCH as unknown as any ;
318308
319- try {
320- await generateTS ( {
309+ await expect (
310+ generateTS ( {
321311 token,
322312 apiKey,
323313 environment,
324314 region,
325315 tokenType,
326316 branch,
327- } ) ;
328- } catch ( err : any ) {
329- expect ( err . error_message ) . toEqual ( "Something went wrong, Bad Request" ) ;
330- }
317+ } )
318+ ) . rejects . toThrow ( ) ;
331319 } ) ;
332320} ) ;
0 commit comments