UNPKG

kentico-cloud-delivery

Version:

Official Kentico Cloud Delivery SDK

71 lines 3.01 kB
import { DeliveryHttpService, sdkInfo } from '../../../lib'; import { Actor, Context, MockQueryService, setup, warriorMovieJson } from '../../setup'; describe('Isolated item', function () { var context = new Context(); setup(context); var mockQueryService = new MockQueryService(context.getConfig(), new DeliveryHttpService(), { host: sdkInfo.host, name: sdkInfo.name, version: sdkInfo.version }); var response; beforeAll(function (done) { response = mockQueryService.mockGetSingleItem(warriorMovieJson, {}); done(); }); it("checks system codename", function () { expect(response.item.system.codename).toEqual('warrior'); }); it("checks system id", function () { expect(response.item.system.id).toEqual('325e2acb-1c14-47f6-af9a-27bc8b6c16fe'); }); it("checks system type", function () { expect(response.item.system.type).toEqual('movie'); }); it("checks last modified", function () { expect(response.item.system.lastModified.toString()).toEqual('2017-06-21T12:22:09.1437891Z'); }); it("checks language", function () { expect(response.item.system.language).toEqual('en'); }); it("checks site map locations", function () { var locations = [ 'main_sitemap' ]; expect(response.item.system.sitemapLocations).toEqual(locations); }); it("checks taxonomy field", function () { expect(response.item.releaseCategory.taxonomyTerms[0].codename).toEqual('global_release'); }); it("checks text field", function () { expect(response.item.title.text).toEqual('Warrior'); }); it("checks datetime field", function () { expect(response.item.released.datetime).toEqual(new Date('2011-09-09T00:00:00Z')); }); it("checks Nunmber field", function () { expect(response.item.length.number).toEqual(151); }); it("checks url slug field", function () { expect(response.item.seoname.getUrl()).toEqual('testSlugUrl/warrior'); }); it("checks assets field", function () { expect(response.item.stars.length).toEqual(2); }); it("checks that modular items are defined", function () { expect(response.item.stars).toBeDefined(); }); it("checks that correct number of modular items are created", function () { expect(response.item.stars.length).toEqual(2); }); it("checks that modular items are of proper type", function () { expect(response.item.stars[0]).toEqual(jasmine.any(Actor)); }); it("checks that text field in first modular item is set", function () { expect(response.item.stars[0].firstName.text).toEqual('Tom'); }); it("checks that text field in second modular item is set", function () { expect(response.item.stars[1].firstName.text).toEqual('Joel'); }); }); //# sourceMappingURL=item.spec.js.map