Skip to content

Commit f8e332f

Browse files
test: ✅ test case for conatinedIn function
1 parent b26a446 commit f8e332f

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

test/api/contenttype.spec.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable no-console */
22
/* eslint-disable promise/always-return */
3-
import { BaseContentType, BaseEntry } from 'src';
3+
import { BaseContentType, BaseEntry, FindResponse } from 'src';
44
import { ContentType } from '../../src/lib/content-type';
55
import { stackInstance } from '../utils/stack-instance';
66
import { 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+
});
2940
function makeContentType(uid = ''): ContentType {
3041
const contentType = stack.ContentType(uid);
3142

test/unit/contenttype.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Entry } from '../../src/lib/entry';
55
import { contentTypeResponseMock } from '../utils/mocks';
66
import { Entries } from '../../src/lib/entries';
77
import { MOCK_CLIENT_OPTIONS } from '../utils/constant';
8+
import { Query } from 'src/lib/query';
89

910
describe('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+
});

0 commit comments

Comments
 (0)