Skip to content

Commit c717b9d

Browse files
authored
Merge pull request #4427 from Cookiezaurs/master
[SER-793]Fixes for views tests
2 parents 124a47a + 0716957 commit c717b9d

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

plugins/views/tests.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ var APP_ID = "";
1313
//recalculate
1414
var myTime = Date.now();
1515
var start = new Date(new Date().getFullYear(), 0, 0);
16+
var startMonth = new Date(new Date().getFullYear(), new Date().getMonth(), 0);
1617

1718
var tableResponse = {};
1819
var userObject = {};
@@ -32,6 +33,7 @@ graphResponse.yesterday = {};
3233
graphResponse["30days"] = {};
3334

3435
var days_this_year;
36+
var days_this_month;
3537

3638
function pushValues(period, index, map) {
3739
for (var key in map) {
@@ -241,7 +243,9 @@ describe('Testing views plugin', function() {
241243
describe('verify empty views tables', function() {
242244
it('should have 0 views', function(done) {
243245
days_this_year = Math.floor((myTime - start) / (1000 * 24 * 60 * 60));
244-
console.log("days left in this year:" + days_this_year);
246+
days_this_month = Math.floor((myTime - startMonth) / (1000 * 24 * 60 * 60));
247+
console.log("days gone in this month:" + days_this_month);
248+
console.log("days gone in this year:" + days_this_year);
245249
API_KEY_ADMIN = testUtils.get("API_KEY_ADMIN");
246250
APP_ID = testUtils.get("APP_ID");
247251
APP_KEY = testUtils.get("APP_KEY");
@@ -300,8 +304,12 @@ describe('Testing views plugin', function() {
300304
tableResponse.yesterday.iTotalRecords += 1;
301305
tableResponse.yesterday.iTotalDisplayRecords += 1;
302306
pushValues("yesterday", 0, {"u": 1, "t": 1, "s": 1, "uvalue": 1, "view": "testview0"});
303-
304-
pushValues("30days", 0, {"u": 1, "t": 1, "s": 1, "uvalue": 1});
307+
if (days_this_month < 2) {
308+
pushValues("30days", 0, {"u": 1, "t": 1, "s": 1});
309+
}
310+
else {
311+
pushValues("30days", 0, {"u": 1, "t": 1, "s": 1, "uvalue": 1});
312+
}
305313

306314
tableResponse["7days"].iTotalRecords += 1;
307315
tableResponse["7days"].iTotalDisplayRecords += 1;
@@ -336,7 +344,13 @@ describe('Testing views plugin', function() {
336344
tableResponse.hour.iTotalRecords += 1;
337345
tableResponse.hour.iTotalDisplayRecords += 1;
338346
pushValues("hour", 0, {"u": 1, "t": 1, "s": 1, "uvalue": 1});
339-
pushValues("30days", 0, {"u": 1, "t": 1, "s": 1, 'uvalue': 1});
347+
348+
if (days_this_month > 1) {
349+
pushValues("30days", 0, {"u": 1, "t": 1, "s": 1});
350+
}
351+
else {
352+
pushValues("30days", 0, {"u": 1, "t": 1, "s": 1, "uvalue": 1});
353+
}
340354

341355
tableResponse.month.iTotalRecords = 1;
342356
tableResponse.month.iTotalDisplayRecords = 1;

0 commit comments

Comments
 (0)