|
| 1 | +describe("dfd.date_range", function(){ |
| 2 | + |
| 3 | + // it("Obtain date between start and end specified", function(){ |
| 4 | + // let d = dfd.date_range({start:'2018-04-24',end:'2018-04-27'}) |
| 5 | + // let rslt = [ |
| 6 | + // '4/24/2018, 1:00:00 AM', |
| 7 | + // '4/25/2018, 1:00:00 AM', |
| 8 | + // '4/26/2018, 1:00:00 AM', |
| 9 | + // '4/27/2018, 1:00:00 AM' |
| 10 | + // ] |
| 11 | + // assert.deepEqual(d,rslt) |
| 12 | + // }); |
| 13 | + it("Obtain date between start with end not specified, but period and freq specified", function(){ |
| 14 | + let d = dfd.date_range({ start:'1/1/2018', period:5, freq:'M' }); |
| 15 | + let rslt = [ |
| 16 | + '1/1/2018, 12:00:00 AM', |
| 17 | + '2/1/2018, 12:00:00 AM', |
| 18 | + '3/1/2018, 12:00:00 AM', |
| 19 | + '4/1/2018, 12:00:00 AM', |
| 20 | + '5/1/2018, 12:00:00 AM' |
| 21 | + ]; |
| 22 | + assert.deepEqual(d, rslt); |
| 23 | + }); |
| 24 | + it("Obtain date between start with end not specified, but period and freq specified, plus offset", function(){ |
| 25 | + let d = dfd.date_range({ start:'1/1/2018', period:5, freq:'3M' }); |
| 26 | + let rslt = [ |
| 27 | + '1/1/2018, 12:00:00 AM', |
| 28 | + '4/1/2018, 12:00:00 AM', |
| 29 | + '7/1/2018, 12:00:00 AM', |
| 30 | + '10/1/2018, 12:00:00 AM', |
| 31 | + '1/1/2019, 12:00:00 AM' |
| 32 | + ]; |
| 33 | + assert.deepEqual(d, rslt); |
| 34 | + }); |
| 35 | + it("Obtain date between start with end not specified, but period and freq specified, plus offset, longer freq", function(){ |
| 36 | + let d = dfd.date_range({ start:'1/1/2018', period:5, freq:'35m' }); |
| 37 | + let rslt = [ |
| 38 | + "1/1/2018, 12:00:00 AM", |
| 39 | + "1/1/2018, 12:35:00 AM", |
| 40 | + "1/1/2018, 1:10:00 AM", |
| 41 | + "1/1/2018, 1:45:00 AM", |
| 42 | + "1/1/2018, 2:20:00 AM" |
| 43 | + ]; |
| 44 | + assert.deepEqual(d, rslt); |
| 45 | + }); |
| 46 | + it("Obtain date range with start not specified but end and period is given", function(){ |
| 47 | + let d = dfd.date_range({ end:'1/1/2018', period:8 }); |
| 48 | + let rslt = [ |
| 49 | + '12/25/2017, 12:00:00 AM', |
| 50 | + '12/26/2017, 12:00:00 AM', |
| 51 | + '12/27/2017, 12:00:00 AM', |
| 52 | + '12/28/2017, 12:00:00 AM', |
| 53 | + '12/29/2017, 12:00:00 AM', |
| 54 | + '12/30/2017, 12:00:00 AM', |
| 55 | + '12/31/2017, 12:00:00 AM', |
| 56 | + '1/1/2018, 12:00:00 AM' |
| 57 | + ]; |
| 58 | + assert.deepEqual(d, rslt); |
| 59 | + }); |
| 60 | + it("inputing wrong freq", function(){ |
| 61 | + assert.throws(function () { dfd.date_range({ end:'1/1/2018', period:8, freq:"d" }); }, Error, 'invalid freq d'); |
| 62 | + }); |
| 63 | + it("inputing wrong freq with offset", function(){ |
| 64 | + assert.throws(function () { dfd.date_range({ end:'1/1/2018', period:8, freq:"4d" }); }, Error, 'invalid freq d'); |
| 65 | + }); |
| 66 | + it("inputing wrong freq offset", function(){ |
| 67 | + assert.throws(function () { dfd.date_range({ end:'1/1/2018', period:8, freq:"abcm" }); }, Error, 'invalid freq offset abc'); |
| 68 | + }); |
| 69 | + // it("Obtain date between start and end specified with different month", function(){ |
| 70 | + |
| 71 | + // let d = dfd.date_range({start:'2018-04-24',end:'2018-05-27'}) |
| 72 | + // let rslt = [ |
| 73 | + // '4/24/2018, 1:00:00 AM', |
| 74 | + // '4/25/2018, 1:00:00 AM', |
| 75 | + // '4/26/2018, 1:00:00 AM', |
| 76 | + // '4/27/2018, 1:00:00 AM', |
| 77 | + // '4/28/2018, 1:00:00 AM', |
| 78 | + // '4/29/2018, 1:00:00 AM', |
| 79 | + // '4/30/2018, 1:00:00 AM', |
| 80 | + // '5/1/2018, 1:00:00 AM', |
| 81 | + // '5/2/2018, 1:00:00 AM', |
| 82 | + // '5/3/2018, 1:00:00 AM', |
| 83 | + // '5/27/2018, 1:00:00 AM' |
| 84 | + // ] |
| 85 | + // assert.deepEqual(d,rslt) |
| 86 | + // }); |
| 87 | +}); |
0 commit comments