Merge pull request #5496 from techAPJ/admin-graphs

FIX: graphs should go to zero for missing dates
This commit is contained in:
Arpit Jalan
2018-01-15 11:10:29 +05:30
committed by GitHub
6 changed files with 51 additions and 9 deletions
+11 -1
View File
@@ -14,7 +14,8 @@ import {
validateUploadedFiles,
getUploadMarkdown,
caretRowCol,
setCaretPosition
setCaretPosition,
fillMissingDates
} from 'discourse/lib/utilities';
import * as Utilities from 'discourse/lib/utilities';
@@ -253,3 +254,12 @@ QUnit.test("caretRowCol", assert => {
document.body.removeChild(textarea);
});
QUnit.test("fillMissingDates", assert => {
const startDate = "2017-11-12"; // YYYY-MM-DD
const endDate = "2017-12-12"; // YYYY-MM-DD
const data = '[{"x":"2017-11-12","y":3},{"x":"2017-11-27","y":2},{"x":"2017-12-06","y":9},{"x":"2017-12-11","y":2}]';
assert.equal(fillMissingDates(JSON.parse(data), startDate, endDate).length, 31,
"it returns a JSON array with 31 dates");
});