Skip to content

Commit c746e27

Browse files
fix: updated tests and types
1 parent 16931a1 commit c746e27

File tree

3 files changed

+29
-30
lines changed

3 files changed

+29
-30
lines changed

index.d.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,17 +154,12 @@ export class ContentType {
154154
constructor();
155155
content_type_uid: string
156156

157-
Query(): TaxonomyQuery;
157+
Query(): Taxonomy;
158158
Entry(uid: string): Entry;
159159
fetch(fetchOptions?: object): Promise<any>;
160160
}
161161

162-
export class Taxonomies {
163-
constructor();
164-
Query(): TaxonomyQuery;
165-
Entry(uid: string): Entry;
166-
fetch(fetchOptions?: object): Promise<any>;
167-
}
162+
export class Taxonomies extends Taxonomy {}
168163

169164
export class Assets {
170165
constructor();
@@ -287,7 +282,7 @@ export class Query extends Entry {
287282
findOne(): Promise<any>;
288283
}
289284

290-
export class TaxonomyQuery extends Query {
285+
export class Taxonomy extends Query {
291286
constructor();
292287
above(key: string, value: string, levels?: number): Query;
293288
equalAndAbove(key: string, value: string, levels?: number): Query;

test/entry/find.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,7 +1364,7 @@ test('.except() - For the reference - Array', function(assert) {
13641364

13651365
// Taxonomies Endpoint
13661366
test('Taxonomies Endpoint: Get Entries With One Term', function(assert) {
1367-
let Query = Stack.Taxonomies().Query();
1367+
let Query = Stack.Taxonomies();
13681368
Query
13691369
.where('taxonomies.one', 'term_one')
13701370
.toJSON()
@@ -1380,7 +1380,7 @@ test('Taxonomies Endpoint: Get Entries With One Term', function(assert) {
13801380
});
13811381

13821382
test('Taxonomies Endpoint: Get Entries With Any Term ($in)', function(assert) {
1383-
let Query = Stack.Taxonomies().Query();
1383+
let Query = Stack.Taxonomies();
13841384
Query
13851385
.containedIn('taxonomies.one', ['term_one', 'term_two'])
13861386
.toJSON()
@@ -1396,9 +1396,9 @@ test('Taxonomies Endpoint: Get Entries With Any Term ($in)', function(assert) {
13961396
})
13971397

13981398
test('Taxonomies Endpoint: Get Entries With Any Term ($or)', function(assert) {
1399-
let Query = Stack.Taxonomies().Query();
1400-
let Query1 = Stack.Taxonomies().Query().where('taxonomies.one', 'term_one');
1401-
let Query2 = Stack.Taxonomies().Query().where('taxonomies.two', 'term_two');
1399+
let Query = Stack.Taxonomies();
1400+
let Query1 = Stack.Taxonomies().where('taxonomies.one', 'term_one');
1401+
let Query2 = Stack.Taxonomies().where('taxonomies.two', 'term_two');
14021402
Query
14031403
.or(Query1, Query2)
14041404
.toJSON()
@@ -1414,9 +1414,9 @@ test('Taxonomies Endpoint: Get Entries With Any Term ($or)', function(assert) {
14141414
})
14151415

14161416
test('Taxonomies Endpoint: Get Entries With All Terms ($and)', function(assert) {
1417-
let Query1 = Stack.Taxonomies().Query().where('taxonomies.one', 'term_one');
1418-
let Query2 = Stack.Taxonomies().Query().where('taxonomies.two', 'term_two');
1419-
let Query = Stack.Taxonomies().Query();
1417+
let Query1 = Stack.Taxonomies().where('taxonomies.one', 'term_one');
1418+
let Query2 = Stack.Taxonomies().where('taxonomies.two', 'term_two');
1419+
let Query = Stack.Taxonomies();
14201420
Query
14211421
.and(Query1, Query2)
14221422
.toJSON()
@@ -1432,7 +1432,7 @@ test('Taxonomies Endpoint: Get Entries With All Terms ($and)', function(assert)
14321432
})
14331433

14341434
test('Taxonomies Endpoint: Get Entries With Any Taxonomy Terms ($exists)', function(assert) {
1435-
let Query = Stack.Taxonomies().Query();
1435+
let Query = Stack.Taxonomies();
14361436
Query
14371437
.exists('taxonomies.one')
14381438
.toJSON()
@@ -1448,7 +1448,7 @@ test('Taxonomies Endpoint: Get Entries With Any Taxonomy Terms ($exists)', funct
14481448
})
14491449

14501450
test('Taxonomies Endpoint: Get Entries With Taxonomy Terms and Also Matching Its Children Term ($eq_below, level)', function(assert) {
1451-
let Query = Stack.Taxonomies().Query();
1451+
let Query = Stack.Taxonomies();
14521452
Query
14531453
.equalAndBelow('taxonomies.one', 'term_one')
14541454
.toJSON()
@@ -1464,7 +1464,7 @@ test('Taxonomies Endpoint: Get Entries With Taxonomy Terms and Also Matching Its
14641464
})
14651465

14661466
test('Taxonomies Endpoint: Get Entries With Taxonomy Terms Children\'s and Excluding the term itself ($below, level)', function(assert) {
1467-
let Query = Stack.Taxonomies().Query();
1467+
let Query = Stack.Taxonomies();
14681468
Query
14691469
.below('taxonomies.one', 'term_one')
14701470
.toJSON()
@@ -1480,7 +1480,7 @@ test('Taxonomies Endpoint: Get Entries With Taxonomy Terms Children\'s and Exclu
14801480
})
14811481

14821482
test('Taxonomies Endpoint: Get Entries With Taxonomy Terms and Also Matching Its Parent Term ($eq_above, level)', function(assert) {
1483-
let Query = Stack.Taxonomies().Query();
1483+
let Query = Stack.Taxonomies();
14841484
Query
14851485
.equalAndAbove('taxonomies.one', 'term_one')
14861486
.toJSON()
@@ -1496,7 +1496,7 @@ test('Taxonomies Endpoint: Get Entries With Taxonomy Terms and Also Matching Its
14961496
})
14971497

14981498
test('Taxonomies Endpoint: Get Entries With Taxonomy Terms Parent and Excluding the term itself ($above, level)', function(assert) {
1499-
let Query = Stack.Taxonomies().Query();
1499+
let Query = Stack.Taxonomies();
15001500
Query
15011501
.above('taxonomies.one', 'term_one_child')
15021502
.toJSON()

test/typescript/entry-query.test.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -403,63 +403,67 @@ describe('Entry Query Test', () => {
403403
done();
404404
});
405405

406-
test('Taxonomy Query: Get entries with any term ($in)', done => {
406+
test('CT Taxonomy Query: Get entries with any term ($in)', done => {
407407
const query = makeEntryQuery().containedIn("taxonomies.taxonomy_uid", ["term_uid1", "term_uid2"]);
408408
expect(query._query).toEqual({"query": {"taxonomies.taxonomy_uid": { "$in": ["term_uid1", "term_uid2"] }}});
409409
done();
410410
});
411411

412-
test('Taxonomy Query: Get entries with any term ($or)', done => {
412+
test('CT Taxonomy Query: Get entries with any term ($or)', done => {
413413
const query1 = makeEntryQuery().where("taxonomies.taxonomy_uid1", "term_uid1");
414414
const query2 = makeEntryQuery().where("taxonomies.taxonomy_uid2", "term_uid2");
415415
const query = makeEntryQuery().or(query1, query2);
416416
expect(query._query).toEqual({"query": { $or: [ {"taxonomies.taxonomy_uid1": "term_uid1"}, {"taxonomies.taxonomy_uid2": "term_uid2"} ] }});
417417
done();
418418
});
419419

420-
test('Taxonomy Query: Get entries with all term ($and)', done => {
420+
test('CT Taxonomy Query: Get entries with all term ($and)', done => {
421421
const query1 = makeEntryQuery().where("taxonomies.taxonomy_uid1", "term_uid1");
422422
const query2 = makeEntryQuery().where("taxonomies.taxonomy_uid2", "term_uid2");
423423
const query = makeEntryQuery().and(query1, query2);
424424
expect(query._query).toEqual({"query": { $and: [ {"taxonomies.taxonomy_uid1": "term_uid1"}, {"taxonomies.taxonomy_uid2": "term_uid2"} ] }});
425425
done();
426426
});
427427

428-
test('Taxonomy Query: Get entries with any taxonomy terms ($exists)', done => {
428+
test('CT Taxonomy Query: Get entries with any taxonomy terms ($exists)', done => {
429429
const query = makeEntryQuery().exists("taxonomies.taxonomy_uid");
430430
expect(query._query).toEqual({"query": {"taxonomies.taxonomy_uid": {$exists: true}}});
431431
done();
432432
});
433433

434-
test('Taxonomy Query: Get entries with taxonomy terms and also matching its children terms ($eq_below, level)', done => {
434+
test('CT Taxonomy Query: Get entries with taxonomy terms and also matching its children terms ($eq_below, level)', done => {
435435
const query = makeEntryQuery().equalAndBelow("taxonomies.taxonomy_uid", "term_uid", 4);
436436
expect(query._query).toEqual({"query": {"taxonomies.taxonomy_uid": {"$eq_below": "term_uid", "levels": 4 }}});
437437
done();
438438
});
439439

440-
test('Taxonomy Query: Get Entries With Taxonomy Terms Children\'s and Excluding the term itself ($below, level) ', done => {
440+
test('CT Taxonomy Query: Get Entries With Taxonomy Terms Children\'s and Excluding the term itself ($below, level) ', done => {
441441
const query = makeEntryQuery().below("taxonomies.taxonomy_uid", "term_uid");
442442
expect(query._query).toEqual({"query": {"taxonomies.taxonomy_uid": {"$below": "term_uid" }}});
443443
done();
444444
});
445445

446-
test('Taxonomy Query: Get Entries With Taxonomy Terms and Also Matching Its Parent Term ($eq_above, level)', done => {
446+
test('CT Taxonomy Query: Get Entries With Taxonomy Terms and Also Matching Its Parent Term ($eq_above, level)', done => {
447447
const query = makeEntryQuery().equalAndAbove("taxonomies.taxonomy_uid", "term_uid", 4);
448448
expect(query._query).toEqual({"query": {"taxonomies.taxonomy_uid": {"$eq_above": "term_uid", "levels": 4 }}});
449449
done();
450450
});
451451

452-
test('Taxonomy Query: Get Entries With Taxonomy Terms Parent and Excluding the term itself ($above, level)', done => {
452+
test('CT Taxonomy Query: Get Entries With Taxonomy Terms Parent and Excluding the term itself ($above, level)', done => {
453453
const query = makeEntryQuery().above("taxonomies.taxonomy_uid", "term_uid", 4);
454454
expect(query._query).toEqual({"query": {"taxonomies.taxonomy_uid": {"$above": "term_uid", "levels": 4 }}});
455455
done();
456456
});
457+
458+
test('Taxonomy find test', done => {
459+
makeTaxonomyQuery().find().then((response) => done()).catch((error) => done());
460+
});
457461
});
458462

459463
function makeEntryQuery() {
460464
return stack.ContentType('uid').Query()
461465
}
462466

463467
function makeTaxonomyQuery() {
464-
return stack.Taxonomies().Query()
468+
return stack.Taxonomies()
465469
}

0 commit comments

Comments
 (0)