forked from contentstack/contentstack-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync-testcases.js
More file actions
114 lines (96 loc) · 3.6 KB
/
sync-testcases.js
File metadata and controls
114 lines (96 loc) · 3.6 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
'use strict';
/*
* Module Dependencies.
*/
const sync_testcase = require('tape');
const Contentstack = require('../../dist/node/contentstack.js');
const init = require('../sync_config.js');
const Utils = require('../entry/utils.js');
const contentTypes = init.contentTypes;
let Stack;
let sync_token = "bltbb61f31a70a572e6c9506a";
var total_count = 123;
var pagination_token = "blt082fd2818f5b2fbd003048";
/*
* Initalise the Contentstack Instance
* */
sync_testcase('Initalise the Contentstack Stack Instance', function(TC) {
setTimeout(function() {
Stack = Contentstack.Stack(init.stack);
Stack.setHost(init.host);
TC.end();
}, 1000);
});
sync_testcase('default .Init()', function(assert) {
Stack
.sync({"init" : true})
.then(function success(data) {
console.log("dtatatata", data)
assert.equal(data.total_count, total_count, "Present Data and Totalcount is equal");
assert.end();
});
});
sync_testcase('default .startdate()', function(assert) {
var date_entry_count = 2
Stack
.sync({"init": true, "start_from": "2018-10-22"})
.then(function success(data) {
console.log("dattatatata", data)
assert.equal(data.total_count, date_entry_count, "Present data and filtered data count on date bases is equal");
assert.end();
});
});
sync_testcase('default .locale()', function(assert) {
var locale_entry_count = 123;
Stack
.sync({"init": "true", "locale": "en-us"})
.then(function success(data) {
assert.equal(data.total_count, locale_entry_count, "Present data and filtered data count on locale bases is equal");
assert.end();
});
});
sync_testcase('default .localeDate()', function(assert) {
var locale_date_entry_count = 2;
Stack
.sync({"init": true, "locale": "en-us", "start_from": "2018-10-22"})
.then(function success(data) {
assert.equal(data.total_count, locale_date_entry_count, "Present data and filtered data count on date and locale bases is equal");
assert.end();
});
});
sync_testcase('default .pagination_token()', function(assert) {
Stack
.sync({"pagination_token" : pagination_token})
.then(function success(result) {
let pagination_count = result.items.length
assert.equal(pagination_count, 23, "pagination_token testcase executed successfully");
assert.end();
});
});
sync_testcase('default .contentTypeUid()', function(assert) {
var contenttype_count = 29;
Stack
.sync({"init": true, "content_type_uid": "session"})
.then(function success(data) {
assert.equal(data.total_count, 31, "Present data and filtered data total count on contentType bases is equal");
assert.end();
});
});
sync_testcase('default .type()', function(assert) {
var items_count = 8;
Stack
.sync({"init": true, "type": "asset_published"})
.then(function success(data) {
assert.equal(data.total_count, items_count, "Present data and filtered data total count on type bases is equal");
assert.end();
});
});
sync_testcase('default .sync_token()', function(assert) {
var sync_expected_count = 2
Stack
.sync({"sync_token" : sync_token})
.then(function success(result) {
assert.equal(result.total_count, sync_expected_count, "Synced Data and Sync_total_count is equal");
assert.end();
});
});