diff --git a/test/data_prep/fake_times_to_close.js b/test/data_prep/fake_times_to_close.js index a0bfffe..65cb938 100644 --- a/test/data_prep/fake_times_to_close.js +++ b/test/data_prep/fake_times_to_close.js @@ -1,18 +1,18 @@ module.exports = [4081119000, 29822000, 33893000, 15058000, 35052000, 14909000,2295000, 337983000, 576754000, 176219000, 585000, 444506000, - 500000, 3038000, 105000, 8512000, 622553000, 257980000, + 500000, 3038000, "105000", 8512000, 622553000, 257980000, 170753000, 2128000, 79324000, 356000, 41285000, 301570000, 874669000, 655254000, 69869000, 207105000, 261634000, 3989000, 84161000, 14965000, 19015000, 149495000, 67029000, 62000, 77736000, 81983000, 177978000, 93900000, 253107000, 1459332000, 4957000, 201000, 111000, 61607000, 4081119000, 29822000, 33893000, 15058000, 35052000, 14909000, - 2295000, 337983000, 576754000, 176219000, 585000, 444506000, + 2295000, 337983000, 576754000, "176219000", 585000, 444506000, 500000, 3038000, 105000, 8512000, 622553000, 257980000, 170753000, 2128000, 79324000, 356000, 41285000, 301570000, 874669000, 655254000, 69869000, 207105000, 261634000, 3989000, - 84161000, 14965000, 19015000, 149495000, 67029000, 62000, - 77736000, 81983000, 177978000, 93900000, 253107000, 1459332000, - 4957000, 201000, 111000, 61607000, 81983000, 177978000, 93900000, - 253107000, 1459332000,4957000, 201000, 111000 + 84161000, 14965000, 19015000, "149495000", 67029000, 62000, + 77736000, 81983000, 177978000, "93900000", 253107000, 1459332000, + 4957000, 201000, "111000", 61607000, 81983000, 177978000, 93900000, + 253107000, "1459332000",4957000, 201000, "111000" ]; diff --git a/test/data_prep/fake_times_to_close_string.js b/test/data_prep/fake_times_to_close_string.js new file mode 100644 index 0000000..7923ab6 --- /dev/null +++ b/test/data_prep/fake_times_to_close_string.js @@ -0,0 +1,22 @@ +module.exports = [ + '4081119000', '29822000', '33893000', '15058000', '35052000', + '14909000', '2295000', '337983000', '576754000', '176219000', + '585000', '444506000', '500000', '3038000', '105000', + '8512000', '622553000', '257980000', '170753000', '2128000', + '79324000', '356000', '41285000', '301570000', '874669000', + '655254000', '69869000', '207105000', '261634000', '3989000', + '84161000', '14965000', '19015000', '149495000', '67029000', + '62000', '77736000', '81983000', '177978000', '93900000', + '253107000', '1459332000', '4957000', '201000', '111000', + '61607000', '4081119000', '29822000', '33893000', '15058000', + '35052000', '14909000', '2295000', '337983000', '576754000', + '176219000', '585000', '444506000', '500000', '3038000', + '105000', '8512000', '622553000', '257980000', '170753000', + '2128000', '79324000', '356000', '41285000', '301570000', + '874669000', '655254000', '69869000', '207105000', '261634000', + '3989000', '84161000', '14965000', '19015000', '149495000', + '67029000', '62000', '77736000', '81983000', '177978000', + '93900000', '253107000', '1459332000', '4957000', '201000', + '111000', '61607000', '81983000', '177978000', '93900000', + '253107000', '1459332000', '4957000', '201000', '111000' +]; \ No newline at end of file diff --git a/test/data_prep/generate_fake_pr_or_issue.js b/test/data_prep/generate_fake_pr_or_issue.js index 60b1395..21d17bc 100644 --- a/test/data_prep/generate_fake_pr_or_issue.js +++ b/test/data_prep/generate_fake_pr_or_issue.js @@ -1,6 +1,6 @@ const headers = require("./fake_header"), - closeTimes = require("./fake_times_to_close"); + closeTimes = require("./fake_times_to_close_string"); function isClosed(state, i) { //this function returns boolean false for open if state is open, @@ -36,7 +36,7 @@ function fakeIssues(howMany, isPrOrIssue, state) { response = { id: new Date().valueOf() +i, //this is hacky, if we ever care about ids //right now we don't really. But be aware. - created_at: now - closeTimes[i], + created_at: (now - closeTimes[i])+"", // simulates strings. Should be handled gracefully. closed: isClosed(state,i), pr_or_issue: prOrIssue, } diff --git a/test/test.js b/test/test.js index 1606916..6fdfc3d 100644 --- a/test/test.js +++ b/test/test.js @@ -52,7 +52,7 @@ ghGetter.fullRun('fakerepo', 'fakeorg', myMocktokit).then(function(result) { // let hammerTime = result.timeToMerge.timeToClose; describe('should return mean time to close correctly', function() { it('for PRs', function() { - assert.equal(hammerTime.pr.mean.ms, 37195311); + assert.strictEqual(hammerTime.pr.mean.ms, 37195311); }); it('for issues', function() { assert.equal(hammerTime.issue.mean.ms, 104784230); @@ -63,7 +63,10 @@ ghGetter.fullRun('fakerepo', 'fakeorg', myMocktokit).then(function(result) { // assert.equal(hammerTime.pr.median.ms, 2295000); }); it('for issues', function() { - assert.equal(hammerTime.issue.median.ms, 176219000); + assert.strictEqual(hammerTime.issue.median.ms, 176219000); + }); + it('should cast string-numbers into real numbers', function(){ + return true; }); }); }); @@ -76,7 +79,7 @@ ghGetter.fullRun('fakerepo', 'fakeorg', myMocktokit).then(function(result) { // it('Should return a middle value with an odd number of entries', function() { var testArr = [5, 2, 1, 3, 4], median = ghGetter.calculateMedian(testArr); - assert.equal(median, 3); + assert.strictEqual(median, 3); }) it('Should return a mean of the middle two value with an even number of entries', function() { var testArr = [6, 1, 5, 4, 2, 3], @@ -88,6 +91,16 @@ ghGetter.fullRun('fakerepo', 'fakeorg', myMocktokit).then(function(result) { // emptyMedian = ghGetter.calculateMedian(emptyArr); assert.equal(emptyMedian, null); }); + it('Should cast strings into ints', function() { + var stringArr = ["900", "100", "10", "3", "1", "2", "9"], + stringMedian = ghGetter.calculateMedian(stringArr); + assert.strictEqual(stringMedian, 2); // numeric median + //9, whether string or int... only returns if the + //array was sorted alphabetically. Neither of these + // next results is okay + assert.notStrictEqual(stringMedian, 9) + assert.notStrictEqual(stringMedian, "9") + }); }); describe('Calculate mean', function() { it('Should correctly calculate the mean of an array', function() {