Skip to content

Commit e8e1ced

Browse files
test: unit and api tests for notExists operator
1 parent a6b3bad commit e8e1ced

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

test/api/contenttype.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,19 @@ describe('ContentType Query API test cases', () => {
4646
expect(query.entries[0].created_at).toBeDefined();
4747
}
4848
});
49+
50+
it('should get entries which does not match the fieldUid - notExists', async () => {
51+
console.log("🚀 ~ makeContentType ~ stack:", await stack.ContentType().find())
52+
53+
const query = await makeContentType('contenttype_uid').Query().notExists('multi_line').find<TEntry>()
54+
if (query.entries) {
55+
expect(query.entries[0]._version).toBeDefined();
56+
expect(query.entries[0].title).toBeDefined();
57+
expect(query.entries[0].uid).toBeDefined();
58+
expect(query.entries[0].created_at).toBeDefined();
59+
expect((query.entries[0] as any).multi_line).not.toBeDefined()
60+
}
61+
});
4962
});
5063
function makeContentType(uid = ''): ContentType {
5164
const contentType = stack.ContentType(uid);

test/unit/contenttype.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,14 @@ describe('ContentType Query class', () => {
5858
});
5959
it('should get entries which matches the fieldUid and values', () => {
6060
const query = contentType.Query().containedIn('fieldUID', ['value']);
61-
expect(query._queryParams).toStrictEqual({'fieldUID': {'$in': ['value']}});
61+
expect(query._parameters).toStrictEqual({'fieldUID': {'$in': ['value']}});
6262
});
6363
it('should get entries which does not match the fieldUid and values', () => {
6464
const query = contentType.Query().notContainedIn('fieldUID', ['value', 'value2']);
65-
expect(query._queryParams).toStrictEqual({'fieldUID': {'$nin': ['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': {'$nin': ['value', 'value2']}});
6670
});
6771
});

0 commit comments

Comments
 (0)