-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e3e5b9d
commit 3ca39b2
Showing
2 changed files
with
95 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
|
||
'use strict'; | ||
|
||
const test = require('tape'); | ||
const Contentstack = require('../../dist/node/contentstack.js'); | ||
|
||
test('should check for values initialized', function(assert) { | ||
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; | ||
assert.equal(livePreviewObject.enable, false); | ||
assert.equal(stack.config.host, 'cdn.contentstack.io'); // rest-preview.contentstack.com | ||
assert.end(); | ||
}); | ||
|
||
test('should check host when live preview is enabled and management token is provided', function(assert) { | ||
const stack = Contentstack.Stack({ | ||
'api_key': process.env.API_KEY, | ||
'delivery_token': process.env.DELIVERY_TOKEN, | ||
'environment': process.env.ENVIRONMENT, | ||
live_preview: { | ||
enable: true, | ||
management_token: 'management_token' | ||
} | ||
}); | ||
const livePreviewObject = stack.config.live_preview; | ||
assert.notEqual(livePreviewObject, 'undefined'); | ||
assert.notEqual(livePreviewObject.enable, 'undefined'); | ||
assert.notEqual(livePreviewObject.host, 'undefined'); | ||
assert.equal(stack.config.host, 'cdn.contentstack.io'); // rest-preview.contentstack.com | ||
assert.end(); | ||
}); | ||
|
||
test('should check host when live preview is disabled and management token is provided', function(assert) { | ||
const stack = Contentstack.Stack({ | ||
'api_key': process.env.API_KEY, | ||
'delivery_token': process.env.DELIVERY_TOKEN, | ||
'environment': process.env.ENVIRONMENT, | ||
live_preview: { | ||
enable: false, | ||
management_token: 'management_token' | ||
} | ||
}); | ||
const livePreviewObject = stack.config.live_preview; | ||
assert.notEqual(livePreviewObject, 'undefined'); | ||
assert.equal(livePreviewObject.enable, false); | ||
assert.notEqual(livePreviewObject.host, 'undefined'); | ||
assert.end(); | ||
}); | ||
|
||
test('should check host when live preview is enabled and preview token is provided', function(assert) { | ||
const stack = Contentstack.Stack({ | ||
'api_key': process.env.API_KEY, | ||
'delivery_token': process.env.DELIVERY_TOKEN, | ||
'environment': process.env.ENVIRONMENT, | ||
live_preview: { | ||
enable: true, | ||
preview_token: 'preview_token' | ||
} | ||
}); | ||
const livePreviewObject = stack.config.live_preview; | ||
assert.notEqual(livePreviewObject, 'undefined'); | ||
assert.notEqual(livePreviewObject.enable, 'undefined'); | ||
assert.notEqual(livePreviewObject.host, 'undefined'); | ||
assert.notEqual(livePreviewObject.preview_token, 'undefined'); | ||
assert.equal(stack.config.host, 'cdn.contentstack.io'); | ||
assert.end(); | ||
}); | ||
|
||
test('should check host when live preview is disabled and preview token is provided', function(assert) { | ||
const stack = Contentstack.Stack({ | ||
'api_key': process.env.API_KEY, | ||
'delivery_token': process.env.DELIVERY_TOKEN, | ||
'environment': process.env.ENVIRONMENT, | ||
live_preview: { | ||
enable: false, | ||
preview_token: 'preview_token' | ||
} | ||
}); | ||
const livePreviewObject = stack.config.live_preview; | ||
assert.notEqual(livePreviewObject, 'undefined'); | ||
assert.notEqual(livePreviewObject.enable, 'undefined'); | ||
assert.notEqual(livePreviewObject.host, 'undefined'); | ||
assert.notEqual(livePreviewObject.preview_token, 'undefined'); | ||
assert.equal(stack.config.host, 'cdn.contentstack.io'); | ||
assert.end(); | ||
}); | ||
|