kentico-cloud-delivery
Version:
Official Kentico Cloud Delivery SDK
29 lines • 1.6 kB
JavaScript
import { Context, setup } from '../../setup';
describe('Base URL', function () {
var context = new Context();
setup(context);
var itemsUrl;
var parsedUrl;
beforeAll(function () {
itemsUrl = context.deliveryClient.items().getUrl();
parsedUrl = new URL(itemsUrl);
});
it("url should be defined", function () { return expect(itemsUrl).toBeDefined(); });
it("protocol should be 'https:'", function () { return expect(parsedUrl.protocol).toEqual('https:'); });
it("host should be 'deliver.kenticocloud.com'", function () { return expect(parsedUrl.host).toEqual('deliver.kenticocloud.com'); });
it("origin should be 'https://deliver.kenticocloud.com'", function () { return expect(parsedUrl.origin).toEqual('https://deliver.kenticocloud.com'); });
it("pathname should contain project id'", function () { return expect(itemsUrl).toContain(context.projectId); });
it("custom base URL should be used'", function () {
var baseUrl = 'http://custombase.com';
var contextCustom = new Context({ baseUrl: baseUrl });
setup(contextCustom);
expect(contextCustom.deliveryClient.items().getUrl()).toContain(baseUrl);
});
it("custom preview URL should be used'", function () {
var previewUrl = 'http://custompreview.com';
var contextCustom = new Context({ basePreviewUrl: previewUrl, usePreviewMode: true });
setup(contextCustom);
expect(contextCustom.deliveryClient.items().getUrl()).toContain(previewUrl);
});
});
//# sourceMappingURL=base-url.spec.js.map