@@ -52,76 +52,76 @@ describe('ContentType Api', () => {
5252 expect ( response . items ) . toBeTruthy ( )
5353 } )
5454
55- describe ( 'Gets content types with cursor pagination' , ( ) => {
56- it ( 'gets content types with cursor pagination with items' , async ( ) => {
57- const response = await readEnvironment . getContentTypesWithCursor ( )
58- expect ( response . items ) . toBeTruthy ( )
59- } )
60-
61- it ( 'returns a cursor paginated content type collection when no query is provided' , async ( ) => {
62- const response = await readEnvironment . getContentTypesWithCursor ( )
63-
64- expect ( response . items ) . not . toHaveLength ( 0 )
65- expect ( response . pages ) . toBeDefined ( )
66- expect ( ( response as { total ?: number } ) . total ) . toBeUndefined ( )
55+ describe ( 'Gets content types with cursor pagination' , ( ) => {
56+ it ( 'gets content types with cursor pagination with items' , async ( ) => {
57+ const response = await readEnvironment . getContentTypesWithCursor ( )
58+ expect ( response . items ) . toBeTruthy ( )
59+ } )
6760
68- response . items . forEach ( ( ct ) => {
69- expect ( ct . sys . type ) . toEqual ( 'ContentType' )
70- expect ( ct . name ) . toBeDefined ( )
71- expect ( ct . fields ) . toBeDefined ( )
72- expect ( Array . isArray ( ct . fields ) ) . toBe ( true )
73- } )
74- } )
61+ it ( 'returns a cursor paginated content type collection when no query is provided' , async ( ) => {
62+ const response = await readEnvironment . getContentTypesWithCursor ( )
7563
76- it ( 'returns [limit] number of items' , async ( ) => {
77- const response = await readEnvironment . getContentTypesWithCursor ( { limit : 3 } )
64+ expect ( response . items ) . not . toHaveLength ( 0 )
65+ expect ( response . pages ) . toBeDefined ( )
66+ expect ( ( response as { total ?: number } ) . total ) . toBeUndefined ( )
7867
79- expect ( response . items ) . toHaveLength ( 3 )
80- expect ( response . pages ) . toBeDefined ( )
81- expect ( ( response as { total ?: number } ) . total ) . toBeUndefined ( )
68+ response . items . forEach ( ( ct ) => {
69+ expect ( ct . sys . type ) . toEqual ( 'ContentType' )
70+ expect ( ct . name ) . toBeDefined ( )
71+ expect ( ct . fields ) . toBeDefined ( )
72+ expect ( Array . isArray ( ct . fields ) ) . toBe ( true )
73+ } )
74+ } )
8275
83- response . items . forEach ( ( ct ) => {
84- expect ( ct . sys . type ) . toEqual ( 'ContentType' )
85- expect ( ct . name ) . toBeDefined ( )
86- expect ( Array . isArray ( ct . fields ) ) . toBe ( true )
87- } )
88- } )
76+ it ( 'returns [limit] number of items' , async ( ) => {
77+ const response = await readEnvironment . getContentTypesWithCursor ( { limit : 3 } )
8978
90- it ( 'supports forward pagination' , async ( ) => {
91- const firstPage = await readEnvironment . getContentTypesWithCursor ( { limit : 2 } )
92- const secondPage = await readEnvironment . getContentTypesWithCursor ( {
93- limit : 2 ,
94- pageNext : firstPage ?. pages ?. next ,
95- } )
79+ expect ( response . items ) . toHaveLength ( 3 )
80+ expect ( response . pages ) . toBeDefined ( )
81+ expect ( ( response as { total ?: number } ) . total ) . toBeUndefined ( )
9682
97- expect ( secondPage . items ) . toHaveLength ( 2 )
98- expect ( firstPage . items [ 0 ] . sys . id ) . not . toEqual ( secondPage . items [ 0 ] . sys . id )
99- } )
83+ response . items . forEach ( ( ct ) => {
84+ expect ( ct . sys . type ) . toEqual ( 'ContentType' )
85+ expect ( ct . name ) . toBeDefined ( )
86+ expect ( Array . isArray ( ct . fields ) ) . toBe ( true )
87+ } )
88+ } )
10089
101- it ( 'should support backward pagination' , async ( ) => {
102- const firstPage = await readEnvironment . getContentTypesWithCursor ( { limit : 2 , order : [ 'sys.createdAt' ] } )
103- const secondPage = await readEnvironment . getContentTypesWithCursor ( {
104- limit : 2 ,
105- pageNext : firstPage ?. pages ?. next ,
106- order : [ 'sys.createdAt' ] ,
107- } )
108- const result = await readEnvironment . getContentTypesWithCursor ( {
109- limit : 2 ,
110- pagePrev : secondPage ?. pages ?. prev ,
111- order : [ 'sys.createdAt' ] ,
112- } )
90+ it ( 'supports forward pagination' , async ( ) => {
91+ const firstPage = await readEnvironment . getContentTypesWithCursor ( { limit : 2 } )
92+ const secondPage = await readEnvironment . getContentTypesWithCursor ( {
93+ limit : 2 ,
94+ pageNext : firstPage ?. pages ?. next ,
95+ } )
11396
114- expect ( result . items ) . toHaveLength ( 2 )
97+ expect ( secondPage . items ) . toHaveLength ( 2 )
98+ expect ( firstPage . items [ 0 ] . sys . id ) . not . toEqual ( secondPage . items [ 0 ] . sys . id )
99+ } )
115100
116- firstPage . items . forEach ( ( item , index ) => {
117- expect ( item . sys . id ) . toEqual ( result . items [ index ] . sys . id )
101+ it ( 'should support backward pagination' , async ( ) => {
102+ const firstPage = await readEnvironment . getContentTypesWithCursor ( {
103+ limit : 2 ,
104+ order : [ 'sys.createdAt' ] ,
105+ } )
106+ const secondPage = await readEnvironment . getContentTypesWithCursor ( {
107+ limit : 2 ,
108+ pageNext : firstPage ?. pages ?. next ,
109+ order : [ 'sys.createdAt' ] ,
110+ } )
111+ const result = await readEnvironment . getContentTypesWithCursor ( {
112+ limit : 2 ,
113+ pagePrev : secondPage ?. pages ?. prev ,
114+ order : [ 'sys.createdAt' ] ,
115+ } )
116+
117+ expect ( result . items ) . toHaveLength ( 2 )
118+
119+ firstPage . items . forEach ( ( item , index ) => {
120+ expect ( item . sys . id ) . toEqual ( result . items [ index ] . sys . id )
121+ } )
122+ } )
118123 } )
119124 } )
120- } )
121-
122-
123-
124- } )
125125
126126 describe ( 'write' , ( ) => {
127127 it ( 'Create, update, publish, getEditorInterface, unpublish and delete content type' , async ( ) => {
0 commit comments