|
1 | 1 | // @flow |
2 | 2 | import {parseHours} from '../parse-hours' |
3 | | -import {dayMoment, hourMoment, moment} from './moment.helper' |
| 3 | +import {dayMoment, plainMoment, hourMoment, moment} from './moment.helper' |
4 | 4 |
|
5 | 5 | it('returns an {open, close} tuple', () => { |
6 | 6 | const now = hourMoment('10:01am') |
@@ -52,3 +52,28 @@ describe('handles wierd times', () => { |
52 | 52 | expect(now.isBetween(open, close)).toBe(true) |
53 | 53 | }) |
54 | 54 | }) |
| 55 | + |
| 56 | +describe('checks a list of schedules to see if any are open', () => { |
| 57 | + const schedule = {days: ['Fr', 'Sa'], from: '10:30am', to: '2:00am'} |
| 58 | + |
| 59 | + it('in normal, non-dst situations', () => { |
| 60 | + const now = plainMoment('06-24-2017 12:00am', 'MM-DD-YYYY h:mma') |
| 61 | + const {open, close} = parseHours(schedule, now) |
| 62 | + expect(open.format('HH:mm')).toBe('10:30') |
| 63 | + expect(close.format('HH:mm')).toBe('02:00') |
| 64 | + }) |
| 65 | + |
| 66 | + it('during the spring-forward dst', () => { |
| 67 | + const now = plainMoment('03-12-2017 12:00am', 'MM-DD-YYYY h:mma') |
| 68 | + const {open, close} = parseHours(schedule, now) |
| 69 | + expect(open.format('HH:mm')).toBe('10:30') |
| 70 | + expect(close.format('HH:mm')).toBe('01:00') |
| 71 | + }) |
| 72 | + |
| 73 | + it('during the fall-back dst', () => { |
| 74 | + const now = plainMoment('11-4-2017 12:00am', 'MM-DD-YYYY h:mma') |
| 75 | + const {open, close} = parseHours(schedule, now) |
| 76 | + expect(open.format('HH:mm')).toBe('10:30') |
| 77 | + expect(close.format('HH:mm')).toBe('02:00') |
| 78 | + }) |
| 79 | +}) |
0 commit comments