Skip to content

Commit 4b8a6ee

Browse files
test: updated unit test cases
1 parent 2724ca9 commit 4b8a6ee

File tree

2 files changed

+32
-27
lines changed

2 files changed

+32
-27
lines changed

test/unit/contenttype.spec.ts

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,3 @@ describe('ContentType class', () => {
4242
expect(response).toEqual(contentTypeResponseMock.content_type);
4343
});
4444
});
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 get entries which matches the fieldUid and values', () => {
60-
const query = contentType.Query().containedIn('fieldUID', ['value']);
61-
expect(query._parameters).toStrictEqual({'fieldUID': {'$in': ['value']}});
62-
});
63-
it('should get entries which does not match the fieldUid and values', () => {
64-
const query = contentType.Query().notContainedIn('fieldUID', ['value', 'value2']);
65-
expect(query._parameters).toStrictEqual({'fieldUID': {'$nin': ['value', 'value2']}});
66-
});
67-
it('should get entries which does not match the fieldUid - notExists', () => {
68-
const query = contentType.Query().notExists('fieldUID');
69-
expect(query._parameters).toStrictEqual({'fieldUID': {'$exists': false}});
70-
});
71-
});

test/unit/entry-queryable.spec.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { AxiosInstance, httpClient } from '@contentstack/core';
2+
import { ContentType } from '../../src/lib/content-type';
3+
import MockAdapter from 'axios-mock-adapter';
4+
import { MOCK_CLIENT_OPTIONS } from '../utils/constant';
5+
6+
7+
describe('Query Operators API test cases', () => {
8+
let contentType: ContentType;
9+
let client: AxiosInstance;
10+
let mockClient: MockAdapter;
11+
12+
beforeAll(() => {
13+
client = httpClient(MOCK_CLIENT_OPTIONS);
14+
mockClient = new MockAdapter(client as any);
15+
});
16+
17+
beforeEach(() => {
18+
contentType = new ContentType(client, 'contentTypeUid');
19+
});
20+
it('should get entries which matches the fieldUid and values', () => {
21+
const query = contentType.Entry().query().containedIn('fieldUID', ['value']);
22+
expect(query._parameters).toStrictEqual({'fieldUID': {'$in': ['value']}});
23+
});
24+
it('should get entries which does not match the fieldUid and values', () => {
25+
const query = contentType.Entry().query().notContainedIn('fieldUID', ['value', 'value2']);
26+
expect(query._parameters).toStrictEqual({'fieldUID': {'$nin': ['value', 'value2']}});
27+
});
28+
it('should get entries which does not match the fieldUid - notExists', () => {
29+
const query = contentType.Entry().query().notExists('fieldUID');
30+
expect(query._parameters).toStrictEqual({'fieldUID': {'$exists': false}});
31+
});
32+
});

0 commit comments

Comments
 (0)