Skip to content

Commit 69bfc82

Browse files
test: unit and api test case for not contained in
1 parent 7018c6d commit 69bfc82

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

test/api/contenttype.spec.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { BaseContentType, BaseEntry, FindResponse } from 'src';
44
import { ContentType } from '../../src/lib/content-type';
55
import { stackInstance } from '../utils/stack-instance';
6-
import { TContentType, TEntry } from './types';
6+
import { TContentType, TEntries, TEntry } from './types';
77
import dotenv from 'dotenv';
88

99
dotenv.config()
@@ -36,6 +36,16 @@ describe('ContentType Query API test cases', () => {
3636
expect(query.entries[0].created_at).toBeDefined();
3737
}
3838
});
39+
40+
it('should test for not Contained In', async () => {
41+
const query = await makeContentType('contenttype_uid').Query().NotContainedIn('title', ['test', 'test2']).find<TEntry>()
42+
if (query.entries) {
43+
expect(query.entries[0]._version).toBeDefined();
44+
expect(query.entries[0].title).toBeDefined();
45+
expect(query.entries[0].uid).toBeDefined();
46+
expect(query.entries[0].created_at).toBeDefined();
47+
}
48+
});
3949
});
4050
function makeContentType(uid = ''): ContentType {
4151
const contentType = stack.ContentType(uid);

test/unit/contenttype.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ describe('ContentType Query class', () => {
5858
});
5959
it('should test for contained In', () => {
6060
const query = contentType.Query().containedIn('fieldUID', ['value']);
61-
expect(query._queryParams).toStrictEqual({'fieldUID': ['value']});
61+
expect(query._queryParams).toStrictEqual({'fieldUID': {'$in': ['value']}});
62+
});
63+
it('should test for not contained In', () => {
64+
const query = contentType.Query().NotContainedIn('fieldUID', ['value', 'value2']);
65+
expect(query._queryParams).toStrictEqual({'fieldUID': {'$nin': ['value', 'value2']}});
6266
});
6367
});

0 commit comments

Comments
 (0)