-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathlive-preview-test.js
More file actions
68 lines (57 loc) · 2.91 KB
/
live-preview-test.js
File metadata and controls
68 lines (57 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
'use strict';
const init = require("../config.js");
const Contentstack = require('../../dist/node/contentstack.js');
describe('Contentstack Live Preview Tests', () => {
test('should check for values initialized', () => {
const stack1 = Contentstack.Stack(init.stack)
const stack = Contentstack.Stack({
'api_key': process.env.API_KEY,
'delivery_token': process.env.DELIVERY_TOKEN,
'environment': process.env.ENVIRONMENT
});
const livePreviewObject = stack.config.live_preview;
expect(livePreviewObject.enable).toBe(false);
expect(stack.config.host).toBe('cdn.contentstack.io'); // rest-preview.contentstack.com
});
test('should check host when live preview is enabled and management token is provided', () => {
init.stack.live_preview.enable = true;
init.stack.live_preview.management_token = 'management_token';
const stack = Contentstack.Stack(init.stack);
const livePreviewObject = stack.config.live_preview;
expect(livePreviewObject).not.toBe('undefined');
expect(livePreviewObject.enable).not.toBe('undefined');
expect(livePreviewObject.host).not.toBe('undefined');
expect(stack.config.host).toBe('cdn.contentstack.io'); // rest-preview.contentstack.com
});
test('should check host when live preview is disabled and management token is provided', () => {
init.stack.live_preview.enable = false;
init.stack.live_preview.management_token = 'management_token';
const stack = Contentstack.Stack(init.stack);
const livePreviewObject = stack.config.live_preview;
expect(livePreviewObject).not.toBe('undefined');
expect(livePreviewObject.enable).toBe(false);
expect(livePreviewObject.host).not.toBe('undefined');
});
test('should check host when live preview is enabled and preview token is provided', () => {
init.stack.live_preview.enable = true;
init.stack.live_preview.preview_token = 'preview_token';
const stack = Contentstack.Stack(init.stack);
const livePreviewObject = stack.config.live_preview;
expect(livePreviewObject).not.toBe('undefined');
expect(livePreviewObject.enable).not.toBe('undefined');
expect(livePreviewObject.host).not.toBe('undefined');
expect(livePreviewObject.preview_token).not.toBe('undefined');
expect(stack.config.host).toBe('cdn.contentstack.io');
});
test('should check host when live preview is disabled and preview token is provided', () => {
init.stack.live_preview.enable = false;
init.stack.live_preview.preview_token = 'preview_token';
const stack = Contentstack.Stack(init.stack);
const livePreviewObject = stack.config.live_preview;
expect(livePreviewObject).not.toBe('undefined');
expect(livePreviewObject.enable).not.toBe('undefined');
expect(livePreviewObject.host).not.toBe('undefined');
expect(livePreviewObject.preview_token).not.toBe('undefined');
expect(stack.config.host).toBe('cdn.contentstack.io');
});
});