File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed
Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change 11/* eslint-disable no-console */
22/* eslint-disable promise/always-return */
3- import { BaseContentType , BaseEntry } from 'src' ;
3+ import { BaseContentType , BaseEntry , FindResponse } from 'src' ;
44import { ContentType } from '../../src/lib/content-type' ;
55import { stackInstance } from '../utils/stack-instance' ;
66import { TContentType , TEntry } from './types' ;
@@ -26,6 +26,17 @@ describe('ContentType API test cases', () => {
2626 expect ( result . schema ) . toBeDefined ( ) ;
2727 } ) ;
2828} ) ;
29+ describe ( 'ContentType Query API test cases' , ( ) => {
30+ it ( 'should test for contained In' , async ( ) => {
31+ const query = await makeContentType ( 'contenttype_uid' ) . Query ( ) . containedIn ( 'title' , [ 'value' ] ) . find < TEntry > ( )
32+ if ( query . entries ) {
33+ expect ( query . entries [ 0 ] . _version ) . toBeDefined ( ) ;
34+ expect ( query . entries [ 0 ] . title ) . toBeDefined ( ) ;
35+ expect ( query . entries [ 0 ] . uid ) . toBeDefined ( ) ;
36+ expect ( query . entries [ 0 ] . created_at ) . toBeDefined ( ) ;
37+ }
38+ } ) ;
39+ } ) ;
2940function makeContentType ( uid = '' ) : ContentType {
3041 const contentType = stack . ContentType ( uid ) ;
3142
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { Entry } from '../../src/lib/entry';
55import { contentTypeResponseMock } from '../utils/mocks' ;
66import { Entries } from '../../src/lib/entries' ;
77import { MOCK_CLIENT_OPTIONS } from '../utils/constant' ;
8+ import { Query } from 'src/lib/query' ;
89
910describe ( 'ContentType class' , ( ) => {
1011 let contentType : ContentType ;
@@ -41,3 +42,22 @@ describe('ContentType class', () => {
4142 expect ( response ) . toEqual ( contentTypeResponseMock . content_type ) ;
4243 } ) ;
4344} ) ;
45+
46+ describe ( 'ContentType Query class' , ( ) => {
47+ let contentType : ContentType ;
48+ let client : AxiosInstance ;
49+ let mockClient : MockAdapter ;
50+
51+ beforeAll ( ( ) => {
52+ client = httpClient ( MOCK_CLIENT_OPTIONS ) ;
53+ mockClient = new MockAdapter ( client as any ) ;
54+ } ) ;
55+
56+ beforeEach ( ( ) => {
57+ contentType = new ContentType ( client , 'contentTypeUid' ) ;
58+ } ) ;
59+ it ( 'should test for contained In' , ( ) => {
60+ const query = contentType . Query ( ) . containedIn ( 'fieldUID' , [ 'value' ] ) ;
61+ expect ( query . _queryParams ) . toStrictEqual ( { 'fieldUID' : [ 'value' ] } ) ;
62+ } ) ;
63+ } ) ;
You can’t perform that action at this time.
0 commit comments