@@ -19,17 +19,17 @@ describe("sort methods", () => {
1919 sort : { fieldName : "recordId" , sortOrder : "descend" } ,
2020 } ) ;
2121 expect ( resp . data . length ) . toBe ( 3 ) ;
22- const firstRecord = parseInt ( resp . data [ 0 ] . fieldData . recordId as string ) ;
23- const secondRecord = parseInt ( resp . data [ 1 ] . fieldData . recordId as string ) ;
22+ const firstRecord = parseInt ( resp . data [ 0 ] ? .fieldData . recordId as string ) ;
23+ const secondRecord = parseInt ( resp . data [ 1 ] ? .fieldData . recordId as string ) ;
2424 expect ( firstRecord ) . toBeGreaterThan ( secondRecord ) ;
2525 } ) ;
2626 test ( "should sort ascending by default" , async ( ) => {
2727 const resp = await layoutClient . list ( {
2828 sort : { fieldName : "recordId" } ,
2929 } ) ;
3030
31- const firstRecord = parseInt ( resp . data [ 0 ] . fieldData . recordId as string ) ;
32- const secondRecord = parseInt ( resp . data [ 1 ] . fieldData . recordId as string ) ;
31+ const firstRecord = parseInt ( resp . data [ 0 ] ? .fieldData . recordId as string ) ;
32+ const secondRecord = parseInt ( resp . data [ 1 ] ? .fieldData . recordId as string ) ;
3333 expect ( secondRecord ) . toBeGreaterThan ( firstRecord ) ;
3434 } ) ;
3535} ) ;
@@ -48,6 +48,7 @@ describe("find methods", () => {
4848 const resp = await client . find ( {
4949 query : { anything : "anything" } ,
5050 } ) ;
51+
5152 expect ( Array . isArray ( resp . data ) ) . toBe ( true ) ;
5253 } ) ;
5354 test ( "successful findFirst with multiple return" , async ( ) => {
@@ -75,18 +76,18 @@ describe("portal methods", () => {
7576 const result = await layoutClient . list ( {
7677 limit : 1 ,
7778 } ) ;
78- expect ( result . data [ 0 ] . portalData . test . length ) . toBe ( 50 ) ; // default portal limit is 50
79+ expect ( result . data [ 0 ] ? .portalData ? .test ? .length ) . toBe ( 50 ) ; // default portal limit is 50
7980
8081 const { data } = await layoutClient . list ( {
8182 limit : 1 ,
8283 portalRanges : { test : { limit : 1 , offset : 2 } } ,
8384 } ) ;
8485 expect ( data . length ) . toBe ( 1 ) ;
8586
86- const portalData = data [ 0 ] . portalData ;
87- const testPortal = portalData . test ;
88- expect ( testPortal . length ) . toBe ( 1 ) ;
89- expect ( testPortal [ 0 ] [ "related::related_field" ] ) . toContain ( "2" ) ; // we should get the 2nd record
87+ const portalData = data [ 0 ] ? .portalData ;
88+ const testPortal = portalData ? .test ;
89+ expect ( testPortal ? .length ) . toBe ( 1 ) ;
90+ expect ( testPortal ?. [ 0 ] ?. [ "related::related_field" ] ) . toContain ( "2" ) ; // we should get the 2nd record
9091 } ) ;
9192 it ( "should update portal data" , async ( ) => {
9293 await layoutClient . update ( {
@@ -106,13 +107,13 @@ describe("portal methods", () => {
106107 } ) ;
107108
108109 expect (
109- "long_and_strange.portalName#forTesting" in data [ 0 ] . portalData ,
110+ "long_and_strange.portalName#forTesting" in ( data ?. [ 0 ] ? .portalData ?? { } ) ,
110111 ) . toBeTruthy ( ) ;
111112
112113 const portalData =
113- data [ 0 ] . portalData [ "long_and_strange.portalName#forTesting" ] ;
114+ data [ 0 ] ? .portalData [ "long_and_strange.portalName#forTesting" ] ;
114115
115- expect ( portalData . length ) . toBeGreaterThan ( 50 ) ;
116+ expect ( portalData ? .length ) . toBeGreaterThan ( 50 ) ;
116117 } ) ;
117118} ) ;
118119
0 commit comments