|
| 1 | +import delivery_date from require 'swift_scheduling' |
| 2 | + |
| 3 | +describe 'swift-scheduling', -> |
| 4 | + it 'NOW translates to two hours later', -> |
| 5 | + result = delivery_date 'NOW', '2012-02-13T09:00:00' |
| 6 | + expected = '2012-02-13T11:00:00' |
| 7 | + assert.are.equal expected, result |
| 8 | + |
| 9 | + pending 'ASAP before one in the afternoon translates to today at five in the afternoon', -> |
| 10 | + result = delivery_date 'ASAP', '1999-06-03T09:45:00' |
| 11 | + expected = '1999-06-03T17:00:00' |
| 12 | + assert.are.equal expected, result |
| 13 | + |
| 14 | + pending 'ASAP at one in the afternoon translates to tomorrow at one in the afternoon', -> |
| 15 | + result = delivery_date 'ASAP', '2008-12-21T13:00:00' |
| 16 | + expected = '2008-12-22T13:00:00' |
| 17 | + assert.are.equal expected, result |
| 18 | + |
| 19 | + pending 'ASAP after one in the afternoon translates to tomorrow at one in the afternoon', -> |
| 20 | + result = delivery_date 'ASAP', '2008-12-21T14:50:00' |
| 21 | + expected = '2008-12-22T13:00:00' |
| 22 | + assert.are.equal expected, result |
| 23 | + |
| 24 | + pending 'EOW on Monday translates to Friday at five in the afternoon', -> |
| 25 | + result = delivery_date 'EOW', '2025-02-03T16:00:00' |
| 26 | + expected = '2025-02-07T17:00:00' |
| 27 | + assert.are.equal expected, result |
| 28 | + |
| 29 | + pending 'EOW on Tuesday translates to Friday at five in the afternoon', -> |
| 30 | + result = delivery_date 'EOW', '1997-04-29T10:50:00' |
| 31 | + expected = '1997-05-02T17:00:00' |
| 32 | + assert.are.equal expected, result |
| 33 | + |
| 34 | + pending 'EOW on Wednesday translates to Friday at five in the afternoon', -> |
| 35 | + result = delivery_date 'EOW', '2005-09-14T11:00:00' |
| 36 | + expected = '2005-09-16T17:00:00' |
| 37 | + assert.are.equal expected, result |
| 38 | + |
| 39 | + pending 'EOW on Thursday translates to Sunday at eight in the evening', -> |
| 40 | + result = delivery_date 'EOW', '2011-05-19T08:30:00' |
| 41 | + expected = '2011-05-22T20:00:00' |
| 42 | + assert.are.equal expected, result |
| 43 | + |
| 44 | + pending 'EOW on Friday translates to Sunday at eight in the evening', -> |
| 45 | + result = delivery_date 'EOW', '2022-08-05T14:00:00' |
| 46 | + expected = '2022-08-07T20:00:00' |
| 47 | + assert.are.equal expected, result |
| 48 | + |
| 49 | + pending 'EOW translates to leap day', -> |
| 50 | + result = delivery_date 'EOW', '2008-02-25T10:30:00' |
| 51 | + expected = '2008-02-29T17:00:00' |
| 52 | + assert.are.equal expected, result |
| 53 | + |
| 54 | + pending '2M before the second month of this year translates to the first workday of the second month of this year', -> |
| 55 | + result = delivery_date '2M', '2007-01-02T14:15:00' |
| 56 | + expected = '2007-02-01T08:00:00' |
| 57 | + assert.are.equal expected, result |
| 58 | + |
| 59 | + pending '11M in the eleventh month translates to the first workday of the eleventh month of next year', -> |
| 60 | + result = delivery_date '11M', '2013-11-21T15:30:00' |
| 61 | + expected = '2014-11-03T08:00:00' |
| 62 | + assert.are.equal expected, result |
| 63 | + |
| 64 | + pending '4M in the ninth month translates to the first workday of the fourth month of next year', -> |
| 65 | + result = delivery_date '4M', '2019-11-18T15:15:00' |
| 66 | + expected = '2020-04-01T08:00:00' |
| 67 | + assert.are.equal expected, result |
| 68 | + |
| 69 | + pending 'Q1 in the first quarter translates to the last workday of the first quarter of this year', -> |
| 70 | + result = delivery_date 'Q1', '2003-01-01T10:45:00' |
| 71 | + expected = '2003-03-31T08:00:00' |
| 72 | + assert.are.equal expected, result |
| 73 | + |
| 74 | + pending 'Q4 in the second quarter translates to the last workday of the fourth quarter of this year', -> |
| 75 | + result = delivery_date 'Q4', '2001-04-09T09:00:00' |
| 76 | + expected = '2001-12-31T08:00:00' |
| 77 | + assert.are.equal expected, result |
| 78 | + |
| 79 | + pending 'Q3 in the fourth quarter translates to the last workday of the third quarter of next year', -> |
| 80 | + result = delivery_date 'Q3', '2022-10-06T11:00:00' |
| 81 | + expected = '2023-09-29T08:00:00' |
| 82 | + assert.are.equal expected, result |
0 commit comments