kentico-cloud-delivery
Version:
Official Kentico Cloud Delivery SDK
45 lines • 2.51 kB
JavaScript
import { flatMap, map } from 'rxjs/operators';
import { Context, setup } from '../../setup';
describe('Live element', function () {
var context = new Context();
setup(context);
var typeCodename = 'movie';
var textElementCodename = 'title';
var multipleChoiceElementCodename = 'category';
var taxonomyElementCodename = 'releasecategory';
var textElementResponse;
var multipleChoiceElementResponse;
var taxonomyElementResponse;
beforeAll(function (done) {
context.deliveryClient.element(typeCodename, textElementCodename)
.getObservable()
.pipe(map(function (r) { return textElementResponse = r; }), flatMap(function () { return context.deliveryClient.element(typeCodename, multipleChoiceElementCodename).getObservable(); }), map(function (r) { return multipleChoiceElementResponse = r; }), flatMap(function () { return context.deliveryClient.element(typeCodename, taxonomyElementCodename).getObservable(); }), map(function (r) { return taxonomyElementResponse = r; }))
.subscribe(function () {
done();
});
});
it("element responses should be defined", function () {
expect(textElementResponse).toBeDefined();
expect(multipleChoiceElementResponse).toBeDefined();
expect(taxonomyElementResponse).toBeDefined();
});
it("element inside responses should be defined", function () {
expect(textElementResponse.element).toBeDefined();
expect(multipleChoiceElementResponse.element).toBeDefined();
expect(taxonomyElementResponse.element).toBeDefined();
});
it("element taxonomy field should contain valid taxonomy group property", function () {
expect(taxonomyElementResponse.element.taxonomyGroup).toBeDefined();
expect(taxonomyElementResponse.element.taxonomyGroup).toEqual(jasmine.any(String));
});
it("multiple choice field should contain options", function () {
expect(multipleChoiceElementResponse.element.options).toBeDefined();
expect(multipleChoiceElementResponse.element.options.length).toBeGreaterThan(0);
});
it("element field should have all required properties defined", function () {
expect(textElementResponse.element.codename).toBeDefined();
expect(textElementResponse.element.name).toBeDefined();
expect(textElementResponse.element.type).toBeDefined();
});
});
//# sourceMappingURL=live-element.spec.js.map