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 1
1
/* eslint-disable no-console */
2
2
/* eslint-disable promise/always-return */
3
- import { BaseContentType , BaseEntry } from 'src' ;
3
+ import { BaseContentType , BaseEntry , FindResponse } from 'src' ;
4
4
import { ContentType } from '../../src/lib/content-type' ;
5
5
import { stackInstance } from '../utils/stack-instance' ;
6
6
import { TContentType , TEntry } from './types' ;
@@ -26,6 +26,17 @@ describe('ContentType API test cases', () => {
26
26
expect ( result . schema ) . toBeDefined ( ) ;
27
27
} ) ;
28
28
} ) ;
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
+ } ) ;
29
40
function makeContentType ( uid = '' ) : ContentType {
30
41
const contentType = stack . ContentType ( uid ) ;
31
42
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { Entry } from '../../src/lib/entry';
5
5
import { contentTypeResponseMock } from '../utils/mocks' ;
6
6
import { Entries } from '../../src/lib/entries' ;
7
7
import { MOCK_CLIENT_OPTIONS } from '../utils/constant' ;
8
+ import { Query } from 'src/lib/query' ;
8
9
9
10
describe ( 'ContentType class' , ( ) => {
10
11
let contentType : ContentType ;
@@ -41,3 +42,22 @@ describe('ContentType class', () => {
41
42
expect ( response ) . toEqual ( contentTypeResponseMock . content_type ) ;
42
43
} ) ;
43
44
} ) ;
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