Skip to content

Commit e3a9bb9

Browse files
Added Test cases
1 parent a29e3c6 commit e3a9bb9

File tree

5 files changed

+28
-53
lines changed

5 files changed

+28
-53
lines changed

index.d.ts

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -300,47 +300,3 @@ export class Taxonomy extends Query {
300300
below(key: string, value: string, levels?: number): Query;
301301
equalAndBelow(key: string, value: string, levels?: number): Query;
302302
}
303-
304-
export class Variants extends Query {
305-
constructor();
306-
307-
entry_uid: string;
308-
content_type_uid: string;
309-
_query: object;
310-
provider: any;
311-
cachePolicy: number;
312-
queryCachePolicy: number;
313-
314-
only(field_uid: string): this;
315-
only(field_uids: string[]): this;
316-
only(reference_field_uid:string, field_uid: string): this;
317-
only(reference_field_uid:string, field_uids: string[]): this;
318-
319-
except(field_uid: string): this;
320-
except(field_uids: string[]): this;
321-
except(reference_field_uid:string, field_uid: string): this;
322-
except(reference_field_uid:string, field_uids: string[]): this;
323-
324-
setCacheProvider(provider: object): this;
325-
setCachePolicy(policy: number): this;
326-
includeReference(val: string[]): this;
327-
includeReference(...val: string[]): this;
328-
language(language_code: string): this;
329-
addQuery(key: string, value: string): this;
330-
includeEmbeddedItems(): this;
331-
includeFallback(): this;
332-
/**
333-
* @deprecated since version 3.3.0
334-
*/
335-
includeSchema(): this;
336-
includeReferenceContentTypeUID(): this;
337-
includeContentType(): this;
338-
/**
339-
* @deprecated since version 3.3.0
340-
*/
341-
includeOwner(): this;
342-
toJSON(): this;
343-
addParam(key: string, value: any): this;
344-
fetch(fetchOptions?: object): Promise<any>;
345-
}
346-

src/core/modules/entry.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as Utils from "../lib/utils";
2-
import Variants from "./variants";
32

43
/**
54
* @class
@@ -389,7 +388,11 @@ export default class Entry {
389388
* @instance
390389
*/
391390
Variants(variant_headers) {
392-
this.headers['x-cs-variant-uid'] = variant_headers;
391+
if (Array.isArray(variant_headers) && variant_headers.length > 0) {
392+
this.headers['x-cs-variant-uid'] = variant_headers.join(',')
393+
}else{
394+
this.headers['x-cs-variant-uid'] = variant_headers;
395+
}
393396
return this;
394397
}
395398

src/core/modules/query.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as Utils from '../lib/utils.js';
22
import Entry from './entry';
3-
import Variants from './variants.js';
43

54
const _extend = {
65
compare: function(type) {
@@ -838,9 +837,11 @@ export default class Query extends Entry {
838837
* @instance
839838
*/
840839
Variants(variant_headers) {
841-
this.headers['x-cs-variant-uid'] = variant_headers;
842-
return this;
840+
if (Array.isArray(variant_headers) && variant_headers.length > 0) {
841+
this.headers['x-cs-variant-uid'] = variant_headers.join(',')
842+
}else{
843+
this.headers['x-cs-variant-uid'] = variant_headers;
844+
}
845+
return this;
843846
}
844-
845-
846847
}

src/core/stack.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import config from '../../config';
22
import * as Utils from './lib/utils';
33
import Entry from './modules/entry';
4-
import Variants from './modules/variants';
54
import Assets from './modules/assets';
65
import Query from './modules/query';
76
import Taxonomy from './modules/taxonomy';

test/entry/find.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1658,4 +1658,20 @@ test('CT Taxonomies Query: Get Entries With Taxonomy Terms Parent and Excluding
16581658
assert.fail("CT Taxonomies Query: Get Entries With Taxonomy Terms Parent and Excluding the term itself ($above, level)");
16591659
assert.end();
16601660
})
1661-
})
1661+
})
1662+
1663+
test('Variants in entry', function (t) {
1664+
let Query = Stack.ContentType('source').Query();
1665+
Query
1666+
.Variants('variant_entry_1', 'variant_entry_2')
1667+
.toJSON()
1668+
.find()
1669+
.then(entries => {
1670+
assert.ok(entries[0].length, 'Variant entries present in the resultset');
1671+
assert.end();
1672+
}, err => {
1673+
console.error("error :", err);
1674+
assert.fail("Variant Entries are not present in the CT");
1675+
assert.end();
1676+
})
1677+
});

0 commit comments

Comments
 (0)