#!perl
use Cassandane::Tiny;

sub test_calendarevent_get_recurrenceid_date_start_datetime
    :min_version_3_5
{
    my ($self) = @_;
    my $jmap = $self->{jmap};
    my $caldav = $self->{caldav};

    my $ical = <<EOF;
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//foo//bar//EN
CALSCALE:GREGORIAN
BEGIN:VEVENT
DTSTART;TZID=Europe/Berlin:20160901T161514
DURATION:PT1H
RRULE:FREQ=DAILY;COUNT=3
UID:2a358cee-6489-4f14-a57f-c104db4dc357
DTSTAMP:20150928T132434Z
CREATED:20150928T125212Z
SUMMARY:test
LAST-MODIFIED:20150928T132434Z
END:VEVENT
BEGIN:VEVENT
RECURRENCE-ID;TZID=Europe/Berlin:20160902T161514
DTSTART;TZID=Europe/Berlin:20160902T161514
DURATION:PT1H
UID:2a358cee-6489-4f14-a57f-c104db4dc357
DTSTAMP:20150928T132434Z
CREATED:20150928T125212Z
SUMMARY:testWithDateTimeRecurId
LAST-MODIFIED:20150928T132434Z
END:VEVENT
BEGIN:VEVENT
RECURRENCE-ID;TZID=Europe/Berlin:20160903
DTSTART;TZID=Europe/Berlin:20160903T161514
DURATION:PT1H
UID:2a358cee-6489-4f14-a57f-c104db4dc357
DTSTAMP:20150928T132434Z
CREATED:20150928T125212Z
SUMMARY:testWithDateRecurId
LAST-MODIFIED:20150928T132434Z
END:VEVENT
END:VCALENDAR
EOF

    my $event = $self->putandget_vevent('2a358cee-6489-4f14-a57f-c104db4dc357',
        $ical, ['recurrenceOverrides']);

    $self->assert_deep_equals({
        '2016-09-02T16:15:14' => {
            title => 'testWithDateTimeRecurId',
        },
        '2016-09-03T16:15:14' => {
            title => 'testWithDateRecurId',
        },
    }, $event->{recurrenceOverrides});
}
