@webitel/api-services 1.0.7 → 1.0.8

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webitel/api-services",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -262,6 +262,77 @@ describe('CalendarsAPI', () => {
262
262
  });
263
263
  });
264
264
 
265
+ it('treats omitted work_start on a working except as midnight (protobuf omits 0)', async () => {
266
+ mockCalendarService.readCalendar.mockResolvedValueOnce({
267
+ data: {
268
+ name: 'Cal',
269
+ timezone: {
270
+ id: 'tz-1',
271
+ },
272
+ excepts: [
273
+ {
274
+ name: 'ff',
275
+ date: 123,
276
+ repeat: true,
277
+ working: true,
278
+ work_stop: 1200,
279
+ },
280
+ ],
281
+ },
282
+ });
283
+
284
+ const result = await CalendarsAPI.get({
285
+ itemId: 1,
286
+ });
287
+
288
+ expect(result.excepts).toEqual([
289
+ {
290
+ name: 'ff',
291
+ date: 123,
292
+ repeat: true,
293
+ working: true,
294
+ workStart: 0,
295
+ workStop: 1200,
296
+ },
297
+ ]);
298
+ });
299
+
300
+ it('keeps midnight (0) holiday workStart/workStop instead of coercing to null', async () => {
301
+ mockCalendarService.readCalendar.mockResolvedValueOnce({
302
+ data: {
303
+ name: 'Cal',
304
+ timezone: {
305
+ id: 'tz-1',
306
+ },
307
+ excepts: [
308
+ {
309
+ name: 'holiday',
310
+ date: 123,
311
+ repeat: true,
312
+ working: true,
313
+ work_start: 0,
314
+ work_stop: 60,
315
+ },
316
+ ],
317
+ },
318
+ });
319
+
320
+ const result = await CalendarsAPI.get({
321
+ itemId: 1,
322
+ });
323
+
324
+ expect(result.excepts).toEqual([
325
+ {
326
+ name: 'holiday',
327
+ date: 123,
328
+ repeat: true,
329
+ working: true,
330
+ workStart: 0,
331
+ workStop: 60,
332
+ },
333
+ ]);
334
+ });
335
+
265
336
  it('defaults accepts to an empty array instead of throwing when missing', async () => {
266
337
  mockCalendarService.readCalendar.mockResolvedValueOnce({
267
338
  data: {
@@ -55,8 +55,8 @@ const mapCalendarToUi = (item: ApiParams) => {
55
55
  date: except.date || 0,
56
56
  repeat: except.repeat || false,
57
57
  working: except.working || false,
58
- workStart: except.workStart || null,
59
- workStop: except.workStop || null,
58
+ workStart: except.workStart ?? (except.working ? 0 : null),
59
+ workStop: except.workStop ?? (except.working ? 0 : null),
60
60
  }));
61
61
  }
62
62
  return {