@@ -22,3 +22,81 @@ describe('getSlotMetrics', () => {
2222 expect ( diff ) . toBe ( 60 )
2323 } )
2424} )
25+
26+ describe ( 'getRange' , ( ) => {
27+ const min = dates . startOf ( new Date ( ) , 'day' )
28+ const max = dates . endOf ( new Date ( ) , 'day' )
29+ const slotMetrics = getSlotMetrics ( { min, max, step : 60 , timeslots : 1 } )
30+
31+ test ( 'getRange: 15 minute start of day appointment stays within calendar' , ( ) => {
32+ let range = slotMetrics . getRange (
33+ new Date ( 2018 , 0 , 29 , 0 , 0 , 0 ) ,
34+ new Date ( 2018 , 0 , 29 , 0 , 15 , 0 )
35+ )
36+ expect ( range . top + range . height ) . toBeLessThan ( 100 )
37+ expect ( range . height ) . toBeGreaterThan ( 0 )
38+ } )
39+
40+ test ( 'getRange: 1 hour start of day appointment stays within calendar' , ( ) => {
41+ let range = slotMetrics . getRange (
42+ new Date ( 2018 , 0 , 29 , 0 , 0 , 0 ) ,
43+ new Date ( 2018 , 0 , 29 , 1 , 0 , 0 )
44+ )
45+ expect ( range . top + range . height ) . toBeLessThan ( 100 )
46+ expect ( range . height ) . toBeGreaterThan ( 0 )
47+ } )
48+
49+ test ( 'getRange: 1 hour mid range appointment stays within calendar' , ( ) => {
50+ let range = slotMetrics . getRange (
51+ new Date ( 2018 , 0 , 29 , 14 , 0 , 0 ) ,
52+ new Date ( 2018 , 0 , 29 , 15 , 0 , 0 )
53+ )
54+ expect ( range . top + range . height ) . toBeLessThan ( 100 )
55+ expect ( range . height ) . toBeGreaterThan ( 0 )
56+ } )
57+
58+ test ( 'getRange: 3 hour mid range appointment stays within calendar' , ( ) => {
59+ let range = slotMetrics . getRange (
60+ new Date ( 2018 , 0 , 29 , 14 , 0 , 0 ) ,
61+ new Date ( 2018 , 0 , 29 , 17 , 0 , 0 )
62+ )
63+ expect ( range . top + range . height ) . toBeLessThan ( 100 )
64+ expect ( range . height ) . toBeGreaterThan ( 0 )
65+ } )
66+
67+ test ( 'getRange: full day appointment stays within calendar' , ( ) => {
68+ let range = slotMetrics . getRange (
69+ new Date ( 2018 , 0 , 29 , 0 , 0 , 0 ) ,
70+ new Date ( 2018 , 0 , 29 , 23 , 59 , 0 )
71+ )
72+ expect ( range . top + range . height ) . toBeLessThan ( 100 )
73+ expect ( range . height ) . toBeGreaterThan ( 0 )
74+ } )
75+
76+ test ( 'getRange: 1 hour end of day appointment stays within calendar' , ( ) => {
77+ let range = slotMetrics . getRange (
78+ new Date ( 2018 , 0 , 29 , 23 , 0 , 0 ) ,
79+ new Date ( 2018 , 0 , 29 , 23 , 59 , 0 )
80+ )
81+ expect ( range . top + range . height ) . toBeLessThan ( 100 )
82+ expect ( range . height ) . toBeGreaterThan ( 0 )
83+ } )
84+
85+ test ( 'getRange: 15 minute end of day appointment stays within calendar' , ( ) => {
86+ let range = slotMetrics . getRange (
87+ new Date ( 2018 , 0 , 29 , 23 , 45 , 0 ) ,
88+ new Date ( 2018 , 0 , 29 , 23 , 59 , 0 )
89+ )
90+ expect ( range . top + range . height ) . toBeLessThan ( 100 )
91+ expect ( range . height ) . toBeGreaterThan ( 0 )
92+ } )
93+
94+ test ( 'getRange: multi day appointment stays within calendar' , ( ) => {
95+ let range = slotMetrics . getRange (
96+ new Date ( 2018 , 0 , 29 , 0 , 0 , 0 ) ,
97+ new Date ( 2018 , 0 , 30 , 4 , 0 , 0 )
98+ )
99+ expect ( range . top + range . height ) . toBeLessThan ( 100 )
100+ expect ( range . height ) . toBeGreaterThan ( 0 )
101+ } )
102+ } )
0 commit comments