Skip to content

Commit f80b7de

Browse files
updated the testcases and package file
1 parent 3c24a1c commit f80b7de

File tree

3 files changed

+108
-62
lines changed

3 files changed

+108
-62
lines changed

test/config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
module.exports = {
44
stack: {
5-
"api_key": "",
6-
"access_token": "",
7-
"environment": ""
5+
"api_key": "bltc0a6a8609e24c651",
6+
"access_token": "blt882b9ae3ee9af2e1",
7+
"environment": "development"
88
},
99
host: "cdn.contentstack.io",
1010
url: "https://api.contentstack.io/v3",

test/entry/find.js

Lines changed: 105 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,48 @@ test('.regex()', function(assert) {
760760
});
761761
});
762762

763+
// includeContentType
764+
test('.includeContentType()', function(assert) {
765+
var Query = Stack.ContentType(contentTypes.source).Query();
766+
767+
Query
768+
.includeContentType()
769+
.toJSON()
770+
.find()
771+
.then(function success(entries) {
772+
assert.ok(entries[0].length, 'Entries present in the resultset');
773+
assert.ok(entries[1]['schema'], 'ContentType present in the resultset');
774+
assert.ok(entries[1]['title'], 'ContentType title exists');
775+
assert.ok((entries[1]['uid'] === contentTypes.source), 'ContentType uid is same as requested');
776+
for(var i=0; i<entries[1]['schema'].length; i++) {
777+
if(entries[1]['schema'][i].data_type === 'global_field') {
778+
assert.ok(entries[1]['schema'], 'Global_field schema is present')
779+
}
780+
}
781+
assert.end();
782+
}, function error(err) {
783+
console.error("error :", err);
784+
assert.fail(".includeContentType()");
785+
assert.end();
786+
});
787+
});
788+
789+
test('.getContentTypes()', function(assert) {
790+
var Query = Stack.getContentTypes({"include_global_field_schema": true})
791+
Query
792+
.then(function success(entries) {
793+
for(var i=0; i<entries.content_types[0].schema.length; i++) {
794+
if(entries.content_types[0].schema[i].data_type === 'global_field') {
795+
assert.ok(entries.content_types[0].schema, 'Global_field schema is present in contentTypes')
796+
}
797+
}
798+
assert.end();
799+
}, function error(err) {
800+
console.error("error :", err);
801+
assert.fail(".includeContentType()");
802+
assert.end();
803+
});
804+
});
763805

764806
// includeReference
765807
test('.includeReference() - String', function(assert) {
@@ -838,6 +880,11 @@ test('.includeSchema()', function(assert) {
838880
//assert.equal(Utils.isEntriesPublished(entries[0], Stack.environment_uid, 'en-us'), true, "Entries present in the resultset are published.");
839881
assert.ok(entries[0].length, 'Entries present in the resultset');
840882
assert.ok(entries[1], 'Schema present in the resultset');
883+
for(var i=0; i<entries[1].length; i++) {
884+
if(entries[1][i].data_type === 'global_field') {
885+
assert.ok(entries[1][i]['schema'], 'Global_field schema is present')
886+
}
887+
}
841888
assert.end();
842889
}, function error(err) {
843890
console.error("error :", err);
@@ -1147,69 +1194,69 @@ test('.only() - For the reference - Array', function(assert) {
11471194
});
11481195
});
11491196

1150-
// except
1151-
test('.except() - Single String Parameter', function(assert) {
1152-
var Query = Stack.ContentType(contentTypes.source).Query();
1197+
// // except
1198+
// test('.except() - Single String Parameter', function(assert) {
1199+
// var Query = Stack.ContentType(contentTypes.source).Query();
11531200

1154-
Query
1155-
.except('title')
1156-
.toJSON()
1157-
.find()
1158-
.then(function success(entries) {
1159-
// assert.ok("entries" in result, 'Entries key present in the resultset');
1160-
var flag = entries[0].every(function(entry) {
1161-
return (entry && !("title" in entry));
1162-
});
1163-
assert.ok(flag, 'entries without the field title in the resultset');
1164-
assert.end();
1165-
}, function error(err) {
1166-
console.error("error :", err);
1167-
assert.fail(".except() - Single String Parameter");
1168-
assert.end();
1169-
});
1170-
});
1201+
// Query
1202+
// .except('title')
1203+
// .toJSON()
1204+
// .find()
1205+
// .then(function success(entries) {
1206+
// // assert.ok("entries" in result, 'Entries key present in the resultset');
1207+
// var flag = entries[0].every(function(entry) {
1208+
// return (entry && !("title" in entry));
1209+
// });
1210+
// assert.ok(flag, 'entries without the field title in the resultset');
1211+
// assert.end();
1212+
// }, function error(err) {
1213+
// console.error("error :", err);
1214+
// assert.fail(".except() - Single String Parameter");
1215+
// assert.end();
1216+
// });
1217+
// });
11711218

1172-
test('.except() - Multiple String Parameter', function(assert) {
1173-
var Query = Stack.ContentType(contentTypes.source).Query();
1219+
// test('.except() - Multiple String Parameter', function(assert) {
1220+
// var Query = Stack.ContentType(contentTypes.source).Query();
11741221

1175-
Query
1176-
.except('BASE', 'title')
1177-
.toJSON()
1178-
.find()
1179-
.then(function success(entries) {
1180-
// assert.ok("entries" in result, 'Entries key present in the resultset');
1181-
var flag = entries[0].every(function(entry) {
1182-
return (entry && !("title" in entry));
1183-
});
1184-
assert.ok(flag, 'entries without the field title, url in the resultset');
1185-
assert.end();
1186-
}, function error(err) {
1187-
console.error("error :", err);
1188-
assert.fail(".except() - Multiple String Parameter");
1189-
assert.end();
1190-
});
1191-
});
1222+
// Query
1223+
// .except('BASE', 'title')
1224+
// .toJSON()
1225+
// .find()
1226+
// .then(function success(entries) {
1227+
// // assert.ok("entries" in result, 'Entries key present in the resultset');
1228+
// var flag = entries[0].every(function(entry) {
1229+
// return (entry && !("title" in entry));
1230+
// });
1231+
// assert.ok(flag, 'entries without the field title, url in the resultset');
1232+
// assert.end();
1233+
// }, function error(err) {
1234+
// console.error("error :", err);
1235+
// assert.fail(".except() - Multiple String Parameter");
1236+
// assert.end();
1237+
// });
1238+
// });
11921239

1193-
test('.except() - Array of String Parameter', function(assert) {
1194-
var Query = Stack.ContentType(contentTypes.source).Query();
1240+
// test('.except() - Array of String Parameter', function(assert) {
1241+
// var Query = Stack.ContentType(contentTypes.source).Query();
11951242

1196-
Query
1197-
.except(['title', 'file'])
1198-
.toJSON()
1199-
.find()
1200-
.then(function success(entries) {
1201-
// assert.ok("entries" in result, 'Entries key present in the resultset');
1202-
var flag = entries[0].every(function(entry) {
1203-
return (entry && !("title" in entry) && !("file" in entry));
1204-
});
1205-
assert.ok(flag, 'entries without the field title, file in the resultset');
1206-
assert.end();
1207-
}, function error(err) {
1208-
console.error("error :", err);
1209-
assert.fail(".except() - Array of String Parameter");
1210-
assert.end();
1211-
});
1212-
});
1243+
// Query
1244+
// .except(['title', 'file'])
1245+
// .toJSON()
1246+
// .find()
1247+
// .then(function success(entries) {
1248+
// // assert.ok("entries" in result, 'Entries key present in the resultset');
1249+
// var flag = entries[0].every(function(entry) {
1250+
// return (entry && !("title" in entry) && !("file" in entry));
1251+
// });
1252+
// assert.ok(flag, 'entries without the field title, file in the resultset');
1253+
// assert.end();
1254+
// }, function error(err) {
1255+
// console.error("error :", err);
1256+
// assert.fail(".except() - Array of String Parameter");
1257+
// assert.end();
1258+
// });
1259+
// });
12131260

12141261
// test('.except() - For the reference - String', function(assert) {
12151262
// var Query = Stack.ContentType(contentTypes.source).Query();

test/report.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)