@webitel/api-services 1.0.11 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -453,6 +453,91 @@ describe('calendarSchema', () => {
|
|
|
453
453
|
).toBe(true);
|
|
454
454
|
}
|
|
455
455
|
});
|
|
456
|
+
|
|
457
|
+
it('rejects overlapping special intervals on the same day', () => {
|
|
458
|
+
const result = calendarSchema.safeParse({
|
|
459
|
+
...minimalValidInput,
|
|
460
|
+
specials: [
|
|
461
|
+
{
|
|
462
|
+
day: 1,
|
|
463
|
+
disabled: false,
|
|
464
|
+
start: 540,
|
|
465
|
+
end: 720,
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
day: 1,
|
|
469
|
+
disabled: false,
|
|
470
|
+
start: 600,
|
|
471
|
+
end: 780,
|
|
472
|
+
},
|
|
473
|
+
],
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
expect(result.success).toBe(false);
|
|
477
|
+
if (!result.success) {
|
|
478
|
+
const intersectIssues = result.error.issues.filter(
|
|
479
|
+
(issue) => issueKey(issue) === 'timerangeNotIntersect',
|
|
480
|
+
);
|
|
481
|
+
expect(intersectIssues.length).toBeGreaterThan(0);
|
|
482
|
+
expect(
|
|
483
|
+
intersectIssues.some(
|
|
484
|
+
(issue) => issue.path.join('.') === 'specials.0.start',
|
|
485
|
+
),
|
|
486
|
+
).toBe(true);
|
|
487
|
+
expect(
|
|
488
|
+
intersectIssues.some(
|
|
489
|
+
(issue) => issue.path.join('.') === 'specials.1.end',
|
|
490
|
+
),
|
|
491
|
+
).toBe(true);
|
|
492
|
+
}
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
it('accepts non-overlapping special intervals on the same day', () => {
|
|
496
|
+
const result = calendarSchema.safeParse({
|
|
497
|
+
...minimalValidInput,
|
|
498
|
+
specials: [
|
|
499
|
+
{
|
|
500
|
+
day: 1,
|
|
501
|
+
disabled: false,
|
|
502
|
+
start: 540,
|
|
503
|
+
end: 600,
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
day: 1,
|
|
507
|
+
disabled: false,
|
|
508
|
+
start: 660,
|
|
509
|
+
end: 720,
|
|
510
|
+
},
|
|
511
|
+
],
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
expect(result.success).toBe(true);
|
|
515
|
+
});
|
|
516
|
+
|
|
517
|
+
it('rejects a special entry with start greater than end', () => {
|
|
518
|
+
const result = calendarSchema.safeParse({
|
|
519
|
+
...minimalValidInput,
|
|
520
|
+
specials: [
|
|
521
|
+
{
|
|
522
|
+
day: 0,
|
|
523
|
+
disabled: false,
|
|
524
|
+
start: 720,
|
|
525
|
+
end: 600,
|
|
526
|
+
},
|
|
527
|
+
],
|
|
528
|
+
});
|
|
529
|
+
|
|
530
|
+
expect(result.success).toBe(false);
|
|
531
|
+
if (!result.success) {
|
|
532
|
+
expect(
|
|
533
|
+
result.error.issues.some(
|
|
534
|
+
(issue) =>
|
|
535
|
+
issueKey(issue) === 'timerangeStartLessThanEnd' &&
|
|
536
|
+
issue.path.join('.') === 'specials.0.start',
|
|
537
|
+
),
|
|
538
|
+
).toBe(true);
|
|
539
|
+
}
|
|
540
|
+
});
|
|
456
541
|
});
|
|
457
542
|
|
|
458
543
|
describe('excepts', () => {
|
|
@@ -209,6 +209,6 @@ export const calendarSchema = z.object<
|
|
|
209
209
|
endAt: z.any().optional(),
|
|
210
210
|
expires: z.boolean().optional().default(false),
|
|
211
211
|
accepts: acceptsOfDayUiArraySchema.default(defaultAccepts),
|
|
212
|
-
specials:
|
|
212
|
+
specials: acceptsOfDayUiArraySchema.default(defaultSpecials),
|
|
213
213
|
excepts: z.array(calendarExceptSchema).optional().default([]),
|
|
214
214
|
});
|