@@ -168,6 +168,18 @@ describe('EditingState', () => {
168168 } ) ;
169169
170170 describe ( 'editing helpers' , ( ) => {
171+ const firstAppointmentInSeries = {
172+ id : 4 ,
173+ startDate : new Date ( Date . UTC ( 2019 , 6 , 15 , 14 , 20 ) ) ,
174+ endDate : new Date ( Date . UTC ( 2019 , 6 , 15 , 16 ) ) ,
175+ rRule : 'FREQ=DAILY;COUNT=5' ,
176+ exDate : '20190716T142000Z' ,
177+ parentData : {
178+ id : 4 ,
179+ startDate : new Date ( Date . UTC ( 2019 , 6 , 15 , 14 , 20 ) ) ,
180+ endDate : new Date ( Date . UTC ( 2019 , 6 , 15 , 16 ) ) ,
181+ } ,
182+ } ;
171183 const appointmentDataBase = {
172184 id : 4 ,
173185 startDate : new Date ( Date . UTC ( 2019 , 6 , 17 , 14 , 20 ) ) ,
@@ -183,39 +195,81 @@ describe('EditingState', () => {
183195 describe ( '#editAll' , ( ) => {
184196 it ( 'should edit simple recurrence' , ( ) => {
185197 const changes = {
186- startDate : new Date ( Date . UTC ( 2019 , 6 , 17 , 14 , 20 ) ) ,
187- endDate : new Date ( Date . UTC ( 2019 , 6 , 17 , 16 ) ) ,
198+ startDate : new Date ( Date . UTC ( 2019 , 6 , 15 , 15 , 20 ) ) ,
199+ endDate : new Date ( Date . UTC ( 2019 , 6 , 15 , 17 ) ) ,
200+ rRule : 'FREQ=DAILY;COUNT=5' ,
201+ } ;
202+
203+ expect ( editAll ( firstAppointmentInSeries , changes ) ) . toEqual ( {
204+ changed : {
205+ 4 : {
206+ startDate : new Date ( Date . UTC ( 2019 , 6 , 15 , 15 , 20 ) ) ,
207+ endDate : new Date ( Date . UTC ( 2019 , 6 , 15 , 17 ) ) ,
208+ rRule : 'FREQ=DAILY;COUNT=5' ,
209+ } ,
210+ } ,
211+ } ) ;
212+ } ) ;
213+ it ( 'should update all appointments using deltas' , ( ) => {
214+ const changes = {
215+ startDate : new Date ( Date . UTC ( 2019 , 6 , 17 , 8 ) ) ,
216+ endDate : new Date ( Date . UTC ( 2019 , 6 , 17 , 19 ) ) ,
188217 rRule : 'FREQ=DAILY;COUNT=5' ,
189218 } ;
190219
191220 expect ( editAll ( appointmentDataBase , changes ) ) . toEqual ( {
192221 changed : {
193222 4 : {
194- startDate : new Date ( Date . UTC ( 2019 , 6 , 17 , 14 , 20 ) ) ,
195- endDate : new Date ( Date . UTC ( 2019 , 6 , 17 , 16 ) ) ,
223+ startDate : new Date ( Date . UTC ( 2019 , 6 , 15 , 8 ) ) ,
224+ endDate : new Date ( Date . UTC ( 2019 , 6 , 15 , 19 ) ) ,
196225 rRule : 'FREQ=DAILY;COUNT=5' ,
197226 } ,
198227 } ,
199228 } ) ;
200229 } ) ;
230+ it ( 'should edit only one date in recurrent appointment' , ( ) => {
231+ const changes = {
232+ startDate : new Date ( Date . UTC ( 2019 , 6 , 17 , 14 , 10 ) ) ,
233+ } ;
234+
235+ expect ( editAll ( appointmentDataBase , changes ) ) . toEqual ( {
236+ changed : {
237+ 4 : {
238+ startDate : new Date ( Date . UTC ( 2019 , 6 , 15 , 14 , 10 ) ) ,
239+ } ,
240+ } ,
241+ } ) ;
242+
243+ const otherChanges = {
244+ endDate : new Date ( Date . UTC ( 2019 , 6 , 17 , 17 ) ) ,
245+ } ;
246+
247+ expect ( editAll ( appointmentDataBase , otherChanges ) ) . toEqual ( {
248+ changed : {
249+ 4 : {
250+ endDate : new Date ( Date . UTC ( 2019 , 6 , 15 , 17 ) ) ,
251+ } ,
252+ } ,
253+ } ) ;
254+ } ) ;
201255 it ( 'should edit if the item is moved after until' , ( ) => {
202256 const appointmentData = {
203- ...appointmentDataBase ,
257+ ...firstAppointmentInSeries ,
204258 startDate : new Date ( Date . UTC ( 2019 , 6 , 17 , 14 , 20 ) ) ,
205259 endDate : new Date ( Date . UTC ( 2019 , 6 , 17 , 16 ) ) ,
206260 rRule : 'FREQ=DAILY;UNTIL=20190717T142000Z' ,
207261 exDate : '20190716T142000Z' ,
208262 } ;
209263 const changes = {
210- startDate : new Date ( Date . UTC ( 2019 , 6 , 18 , 14 , 20 ) ) ,
211- endDate : new Date ( Date . UTC ( 2019 , 6 , 18 , 16 ) ) ,
264+ startDate : new Date ( Date . UTC ( 2019 , 8 , 18 , 14 , 20 ) ) ,
265+ endDate : new Date ( Date . UTC ( 2019 , 8 , 18 , 16 ) ) ,
212266 } ;
213267
214268 expect ( editAll ( appointmentData , changes ) ) . toEqual ( {
215269 changed : {
216270 4 : {
217- startDate : new Date ( Date . UTC ( 2019 , 6 , 18 , 14 , 20 ) ) ,
218- endDate : new Date ( Date . UTC ( 2019 , 6 , 18 , 16 ) ) ,
271+ startDate : new Date ( Date . UTC ( 2019 , 8 , 18 , 14 , 20 ) ) ,
272+ endDate : new Date ( Date . UTC ( 2019 , 8 , 18 , 16 ) ) ,
219273 rRule : 'FREQ=DAILY;COUNT=1' ,
220274 exDate : '' ,
221275 } ,
@@ -224,7 +278,7 @@ describe('EditingState', () => {
224278 } ) ;
225279 it ( 'should edit if changes\' startDate is undefined' , ( ) => {
226280 const appointmentData = {
227- ...appointmentDataBase ,
281+ ...firstAppointmentInSeries ,
228282 rRule : 'FREQ=DAILY;UNTIL=20190717T142000Z' ,
229283 } ;
230284 const changes = {
@@ -360,8 +414,8 @@ describe('EditingState', () => {
360414 } ,
361415 } ;
362416 const changes = {
363- startDate : new Date ( Date . UTC ( 2019 , 6 , 15 , 11 , 20 ) ) ,
364- endDate : new Date ( Date . UTC ( 2019 , 6 , 15 , 14 ) ) ,
417+ startDate : new Date ( Date . UTC ( 2019 , 6 , 16 , 11 , 20 ) ) ,
418+ endDate : new Date ( Date . UTC ( 2019 , 6 , 16 , 14 ) ) ,
365419 } ;
366420
367421 expect ( editCurrentAndFollowing ( appointmentData , changes ) ) . toEqual ( {
0 commit comments