1
1
'use strict' ;
2
+ const init = require ( "../config.js" ) ;
2
3
3
4
const Contentstack = require ( '../../dist/node/contentstack.js' ) ;
4
5
5
6
describe ( 'Contentstack Live Preview Tests' , ( ) => {
6
7
test ( 'should check for values initialized' , ( ) => {
8
+ const stack1 = Contentstack . Stack ( init . stack )
7
9
const stack = Contentstack . Stack ( {
8
- 'api_key' : process . env . region_API_KEY ,
10
+ 'api_key' : process . env . API_KEY ,
9
11
'delivery_token' : process . env . DELIVERY_TOKEN ,
10
12
'environment' : process . env . ENVIRONMENT
11
13
} ) ;
@@ -16,15 +18,9 @@ describe('Contentstack Live Preview Tests', () => {
16
18
} ) ;
17
19
18
20
test ( 'should check host when live preview is enabled and management token is provided' , ( ) => {
19
- const stack = Contentstack . Stack ( {
20
- 'api_key' : process . env . API_KEY ,
21
- 'delivery_token' : process . env . DELIVERY_TOKEN ,
22
- 'environment' : process . env . ENVIRONMENT ,
23
- live_preview : {
24
- enable : true ,
25
- management_token : 'management_token'
26
- }
27
- } ) ;
21
+ init . stack . live_preview . enable = true ;
22
+ init . stack . live_preview . management_token = 'management_token' ;
23
+ const stack = Contentstack . Stack ( init . stack ) ;
28
24
29
25
const livePreviewObject = stack . config . live_preview ;
30
26
expect ( livePreviewObject ) . not . toBe ( 'undefined' ) ;
@@ -34,15 +30,9 @@ describe('Contentstack Live Preview Tests', () => {
34
30
} ) ;
35
31
36
32
test ( 'should check host when live preview is disabled and management token is provided' , ( ) => {
37
- const stack = Contentstack . Stack ( {
38
- 'api_key' : process . env . API_KEY ,
39
- 'delivery_token' : process . env . DELIVERY_TOKEN ,
40
- 'environment' : process . env . ENVIRONMENT ,
41
- live_preview : {
42
- enable : false ,
43
- management_token : 'management_token'
44
- }
45
- } ) ;
33
+ init . stack . live_preview . enable = false ;
34
+ init . stack . live_preview . management_token = 'management_token' ;
35
+ const stack = Contentstack . Stack ( init . stack ) ;
46
36
47
37
const livePreviewObject = stack . config . live_preview ;
48
38
expect ( livePreviewObject ) . not . toBe ( 'undefined' ) ;
@@ -51,15 +41,9 @@ describe('Contentstack Live Preview Tests', () => {
51
41
} ) ;
52
42
53
43
test ( 'should check host when live preview is enabled and preview token is provided' , ( ) => {
54
- const stack = Contentstack . Stack ( {
55
- 'api_key' : process . env . API_KEY ,
56
- 'delivery_token' : process . env . DELIVERY_TOKEN ,
57
- 'environment' : process . env . ENVIRONMENT ,
58
- live_preview : {
59
- enable : true ,
60
- preview_token : 'preview_token'
61
- }
62
- } ) ;
44
+ init . stack . live_preview . enable = true ;
45
+ init . stack . live_preview . preview_token = 'preview_token' ;
46
+ const stack = Contentstack . Stack ( init . stack ) ;
63
47
64
48
const livePreviewObject = stack . config . live_preview ;
65
49
expect ( livePreviewObject ) . not . toBe ( 'undefined' ) ;
@@ -70,15 +54,9 @@ describe('Contentstack Live Preview Tests', () => {
70
54
} ) ;
71
55
72
56
test ( 'should check host when live preview is disabled and preview token is provided' , ( ) => {
73
- const stack = Contentstack . Stack ( {
74
- 'api_key' : process . env . API_KEY ,
75
- 'delivery_token' : process . env . DELIVERY_TOKEN ,
76
- 'environment' : process . env . ENVIRONMENT ,
77
- live_preview : {
78
- enable : false ,
79
- preview_token : 'preview_token'
80
- }
81
- } ) ;
57
+ init . stack . live_preview . enable = false ;
58
+ init . stack . live_preview . preview_token = 'preview_token' ;
59
+ const stack = Contentstack . Stack ( init . stack ) ;
82
60
83
61
const livePreviewObject = stack . config . live_preview ;
84
62
expect ( livePreviewObject ) . not . toBe ( 'undefined' ) ;
0 commit comments