Skip to content
This repository was archived by the owner on Dec 30, 2025. It is now read-only.

Commit 35debd0

Browse files
update tests
1 parent 4a6eb76 commit 35debd0

File tree

1 file changed

+70
-16
lines changed

1 file changed

+70
-16
lines changed

packages/dx-scheduler-core/src/plugins/editing-state/helpers.test.ts

Lines changed: 70 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,23 @@ describe('EditingState', () => {
168168
});
169169

170170
describe('editing helpers', () => {
171-
const appointmentDataBase = {
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=2',
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+
};
183+
const secondAppointmentInSeries = {
172184
id: 4,
173185
startDate: new Date(Date.UTC(2019, 6, 17, 14, 20)),
174186
endDate: new Date(Date.UTC(2019, 6, 17, 16)),
175-
rRule: 'FREQ=DAILY;COUNT=5',
187+
rRule: 'FREQ=DAILY;COUNT=2',
176188
exDate: '20190716T142000Z',
177189
parentData: {
178190
id: 4,
@@ -183,24 +195,66 @@ 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)),
188-
rRule: 'FREQ=DAILY;COUNT=5',
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=2',
189201
};
190202

191-
expect(editAll(appointmentDataBase, changes)).toEqual({
203+
expect(editAll(firstAppointmentInSeries, changes)).toEqual({
192204
changed: {
193205
4: {
194-
startDate: new Date(Date.UTC(2019, 6, 17, 14, 20)),
195-
endDate: new Date(Date.UTC(2019, 6, 17, 16)),
196-
rRule: 'FREQ=DAILY;COUNT=5',
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=2',
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)),
217+
rRule: 'FREQ=DAILY;COUNT=2',
218+
};
219+
220+
expect(editAll(secondAppointmentInSeries, changes)).toEqual({
221+
changed: {
222+
4: {
223+
startDate: new Date(Date.UTC(2019, 6, 15, 8)),
224+
endDate: new Date(Date.UTC(2019, 6, 15, 19)),
225+
rRule: 'FREQ=DAILY;COUNT=2',
226+
},
227+
},
228+
});
229+
});
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(secondAppointmentInSeries, 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(secondAppointmentInSeries, otherChanges)).toEqual({
248+
changed: {
249+
4: {
250+
endDate: new Date(Date.UTC(2019, 6, 15, 17)),
197251
},
198252
},
199253
});
200254
});
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',
@@ -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 = {
@@ -248,7 +302,7 @@ describe('EditingState', () => {
248302
endDate: new Date(Date.UTC(2019, 6, 17, 16)),
249303
};
250304

251-
expect(editCurrent(appointmentDataBase, changes)).toEqual({
305+
expect(editCurrent(secondAppointmentInSeries, changes)).toEqual({
252306
changed: {
253307
4: {
254308
exDate: '20190716T142000Z,20190717T142000Z',
@@ -268,7 +322,7 @@ describe('EditingState', () => {
268322
endDate: new Date(Date.UTC(2019, 6, 17, 16)),
269323
};
270324

271-
expect(editCurrent({ ...appointmentDataBase, exDate: '' }, changes)).toEqual({
325+
expect(editCurrent({ ...secondAppointmentInSeries, exDate: '' }, changes)).toEqual({
272326
changed: {
273327
4: {
274328
exDate: '20190717T142000Z',
@@ -287,7 +341,7 @@ describe('EditingState', () => {
287341
title: 'Next title',
288342
};
289343

290-
expect(editCurrent(appointmentDataBase, changes)).toEqual({
344+
expect(editCurrent(secondAppointmentInSeries, changes)).toEqual({
291345
changed: {
292346
4: {
293347
exDate: '20190716T142000Z,20190717T142000Z',
@@ -305,7 +359,7 @@ describe('EditingState', () => {
305359
describe('#editCurrentAndFollowing', () => {
306360
it('should work with excluded days', () => {
307361
const appointmentData = {
308-
...appointmentDataBase,
362+
...secondAppointmentInSeries,
309363
startDate: new Date(Date.UTC(2019, 6, 18, 14, 20)),
310364
endDate: new Date(Date.UTC(2019, 6, 18, 16)),
311365
};
@@ -332,7 +386,7 @@ describe('EditingState', () => {
332386
title: 'Next title',
333387
};
334388

335-
expect(editCurrentAndFollowing(appointmentDataBase, changes)).toEqual({
389+
expect(editCurrentAndFollowing(secondAppointmentInSeries, changes)).toEqual({
336390
changed: {
337391
4: {
338392
rRule: 'FREQ=DAILY;UNTIL=20190715T142000Z',

0 commit comments

Comments
 (0)