UNPKG

kentico-cloud-delivery

Version:

Official Kentico Cloud Delivery SDK

96 lines 4.33 kB
"use strict"; exports.__esModule = true; var lib_1 = require("../../../lib"); var setup_1 = require("../../setup"); describe('Live item', function () { var context = new setup_1.Context(); setup_1.setup(context); var movieCodename = 'warrior'; var response; beforeAll(function (done) { context.deliveryClient.item(movieCodename) .getObservable() .subscribe(function (r) { response = r; done(); }); }); it("item response should be defined", function () { expect(response).toBeDefined(); }); it("item should be defined", function () { expect(response.item).toBeDefined(); }); it("item should be instance of 'Movie' class", function () { expect(response.item).toEqual(jasmine.any(setup_1.Movie)); }); it("item should be instance of 'Movie' class", function () { expect(response.item).toEqual(jasmine.any(setup_1.Movie)); }); it("title should be 'Warrior'", function () { expect(response.item.title.text).toEqual('Warrior'); }); it("verify 'plot' rich text field with modular content contains expected html", function () { var html = response.item.plot.getHtml(); expect(html).toContain('<p>Tom</p>'); }); it("released date should be '2011-09-09T00:00:00Z'", function () { expect(response.item.released.datetime).toEqual(new Date('2011-09-09T00:00:00Z')); }); it("poster asset should be defined", function () { expect(response.item.poster).toBeDefined(); }); it("poster asset' url should be set", function () { expect(response.item.poster.assets[0].url).toEqual('https://assets.kenticocloud.com:443/da5abe9f-fdad-4168-97cd-b3464be2ccb9/22504ba8-2075-48fa-9d4f-8fce3de1754a/warrior.jpg'); }); it("category options should be defined", function () { expect(response.item.category.options).toBeDefined(); }); it("there should be 2 category options defined", function () { expect(response.item.category.options.length).toEqual(2); }); it("checks codename of first category option", function () { expect(response.item.category.options[0].codename).toEqual('action'); }); it("checks codename of second category option", function () { expect(response.item.category.options[1].codename).toEqual('drama'); }); it("checks that category options are of proper type", function () { expect(response.item.category.options[1]).toEqual(jasmine.any(lib_1.FieldModels.MultipleChoiceOption)); }); it("stars modular items should be defined", function () { expect(response.item.stars).toBeDefined(); }); it("check number of stars items", function () { expect(response.item.stars.length).toEqual(2); }); it("check that type of stars property is correct", function () { expect(response.item.stars[0]).toEqual(jasmine.any(setup_1.Actor)); }); it("Check that modular item (Actor) has 'firstName' text properly assigned", function () { expect(response.item.stars[0].firstName.text).toEqual('Tom'); }); it("url slug field should be defined", function () { expect(response.item.seoname).toBeDefined(); }); it("url of url slug field should be resolved", function () { expect(response.item.seoname.getUrl()).toEqual('testSlugUrl/warrior'); }); it("checks that html contains resolved modular content #1", function () { var expectedHtml = "<p>Tom</p>"; expect(response.item.plot.getHtml()).toContain(expectedHtml); }); it("checks that html contains resolved modular content #2", function () { var expectedHtml = "<p>Joel</p>"; expect(response.item.plot.getHtml()).toContain(expectedHtml); }); it("checks that html contains resolved url #1", function () { var expectedHtml = "/actor/tom"; expect(response.item.plot.getHtml()).toContain(expectedHtml); }); it("checks that html contains resolved url #2", function () { var expectedHtml = "/actor/joel"; expect(response.item.plot.getHtml()).toContain(expectedHtml); }); }); //# sourceMappingURL=live-item.spec.js.map