kentico-cloud-delivery
Version:
Official Kentico Cloud Delivery SDK
36 lines • 2.1 kB
JavaScript
import { Context, setup } from '../../setup';
describe('Preview headers', function () {
var context = new Context({
usePreviewMode: true
});
setup(context);
it("preview authorization header should be defined when getting items (global config)'", function () {
var headers = context.deliveryClient.items().getHeaders();
var authorizationHeader = headers.find(function (m) { return m.header === 'authorization'; });
expect(authorizationHeader).toBeDefined();
});
it("preview authorization header should be defined when getting taxonomies (global config)'", function () {
var headers = context.deliveryClient.types().getHeaders();
var authorizationHeader = headers.find(function (m) { return m.header === 'authorization'; });
expect(authorizationHeader).toBeDefined();
});
it("preview authorization header should be defined for getting types (global config)'", function () {
var headers = context.deliveryClient.taxonomies().getHeaders();
var authorizationHeader = headers.find(function (m) { return m.header === 'authorization'; });
expect(authorizationHeader).toBeDefined();
});
it("preview authorization header should contain preview API key (global config)'", function () {
var headers = context.deliveryClient.items().getHeaders();
var authorizationHeader = headers.find(function (m) { return m.header === 'authorization'; });
var expectedValue = 'bearer ' + context.previewApiKey;
expect(authorizationHeader.value).toEqual(expectedValue);
});
it("preview authorization header should NOT be defined when QueryConfig specifically disables it'", function () {
var headers = context.deliveryClient.items().queryConfig({
usePreviewMode: false
}).getHeaders();
var authorizationHeader = headers.find(function (m) { return m.header === 'authorization'; });
expect(authorizationHeader).toBeUndefined();
});
});
//# sourceMappingURL=preview-headers.spec.js.map