kentico-cloud-delivery
Version:
Official Kentico Cloud Delivery SDK
67 lines • 2.96 kB
JavaScript
import { setup, Context } from '../../setup';
describe('Live taxonomies', function () {
var context = new Context();
setup(context);
var termsWithNestedTermsCodename = 'film'; // codename of the taxonomy term that has nested terms
var numberOfNestedTerms = 3; // this is the number of nested terms defined by 'termsWithNestedTermsCodename'
var existingTaxonomyCodename = 'movietype'; // codename of some of the defined taxonomies
var numberOfTaxonomies = 2; // number of defined taxonomies
var response;
var taxonomy;
beforeAll(function (done) {
context.deliveryClient.taxonomies()
.getObservable()
.subscribe(function (r) {
response = r;
taxonomy = response.taxonomies.find(function (m) { return m.system.codename === existingTaxonomyCodename; });
done();
});
});
it("taxonomies should have pagination", function () {
expect(response.pagination).toBeDefined();
});
it("taxonomies should be defined", function () {
expect(response.taxonomies).toBeDefined();
});
it("there should be '" + numberOfTaxonomies + "' taxonomies", function () {
expect(response.taxonomies.length).toEqual(numberOfTaxonomies);
});
it("taxonomy with codename '" + existingTaxonomyCodename + "' should be defined", function () {
expect(taxonomy).toBeDefined();
});
it("taxomy system attributes should be defined", function () {
if (!taxonomy) {
throw Error('undefined');
}
expect(taxonomy.system).toBeDefined();
expect(taxonomy.system.codename).toBeDefined();
expect(taxonomy.system.id).toBeDefined();
expect(taxonomy.system.lastModified).toBeDefined();
expect(taxonomy.system.name).toBeDefined();
});
it("taxonomy group should match requested type", function () {
if (!taxonomy) {
throw Error('undefined');
}
expect(taxonomy.system.codename).toEqual(existingTaxonomyCodename);
});
it("taxonomy group should have defined terms", function () {
if (!taxonomy) {
throw Error('undefined');
}
expect(taxonomy.terms).toBeDefined();
});
it("taxonomy group should have > 0 terms", function () {
if (!taxonomy) {
throw Error('undefined');
}
expect(taxonomy.terms.length).toBeGreaterThan(0);
});
it("taxonomy group should contain nested taxonomies", function () {
var termsWithNestedTerms = taxonomy.terms.find(function (m) { return m.codename === termsWithNestedTermsCodename; });
expect(termsWithNestedTerms).toBeDefined();
expect(termsWithNestedTerms.terms).toBeDefined();
expect(termsWithNestedTerms.terms.length).toEqual(numberOfNestedTerms);
});
});
//# sourceMappingURL=live-taxonomies.spec.js.map