|
| 1 | +/** |
| 2 | + * CDAV Library |
| 3 | + * |
| 4 | + * This library is part of the Nextcloud project |
| 5 | + * |
| 6 | + * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors |
| 7 | + * SPDX-License-Identifier: AGPL-3.0-or-later |
| 8 | + */ |
| 9 | + |
| 10 | +import { describe, expect, it } from 'vitest' |
| 11 | + |
| 12 | +import { DeletedCalendarObject } from '../../../src/models/deletedCalendarObject.js' |
| 13 | +import { VObject } from '../../../src/models/vobject.js' |
| 14 | +import RequestMock from '../../mocks/request.mock.js' |
| 15 | +import { DavCollection as DavCollectionMock } from '../../mocks/davCollection.mock.js' |
| 16 | + |
| 17 | +describe('DeletedCalendarObject model', () => { |
| 18 | + |
| 19 | + it('should inherit from VObject', () => { |
| 20 | + const parent = new DavCollectionMock() |
| 21 | + const request = new RequestMock() |
| 22 | + const url = '/trash-bin/objects/deleted.ics' |
| 23 | + const props = { |
| 24 | + '{DAV:}getetag': '"etag"', |
| 25 | + '{DAV:}getcontenttype': 'text/calendar', |
| 26 | + '{DAV:}resourcetype': [], |
| 27 | + '{urn:ietf:params:xml:ns:caldav}calendar-data': 'BEGIN:VCALENDAR\nEND:VCALENDAR', |
| 28 | + } |
| 29 | + |
| 30 | + const object = new DeletedCalendarObject(parent, request, url, props) |
| 31 | + expect(object).toEqual(expect.any(VObject)) |
| 32 | + }) |
| 33 | + |
| 34 | + it('should expose deleted calendar object properties', () => { |
| 35 | + const parent = new DavCollectionMock() |
| 36 | + const request = new RequestMock() |
| 37 | + const url = '/trash-bin/objects/deleted.ics' |
| 38 | + const props = { |
| 39 | + '{DAV:}getetag': '"etag"', |
| 40 | + '{DAV:}getcontenttype': 'text/calendar', |
| 41 | + '{DAV:}resourcetype': [], |
| 42 | + '{urn:ietf:params:xml:ns:caldav}calendar-data': 'BEGIN:VCALENDAR\nEND:VCALENDAR', |
| 43 | + '{http://nextcloud.com/ns}calendar-uri': 'calendar-1', |
| 44 | + '{http://nextcloud.com/ns}source-calendar-uri': 'source', |
| 45 | + '{http://nextcloud.com/ns}calendar-owner-principal-uri': 'principals/users/user', |
| 46 | + '{http://nextcloud.com/ns}deleted-at': new Date('2026-05-20T10:11:12Z'), |
| 47 | + } |
| 48 | + |
| 49 | + const object = new DeletedCalendarObject(parent, request, url, props) |
| 50 | + |
| 51 | + expect(object.calendarUri).toEqual('calendar-1') |
| 52 | + expect(object.sourceCalendarUri).toEqual('source') |
| 53 | + expect(object.calendarOwnerPrincipalUri).toEqual('principals/users/user') |
| 54 | + expect(object.deletedAt).toEqual(new Date('2026-05-20T10:11:12Z')) |
| 55 | + }) |
| 56 | + |
| 57 | +}) |
0 commit comments