#!perl
use Cassandane::Tiny;

sub test_calendarevent_get_virtuallocations_conference
    :min_version_3_1
    ($self)
{
    my ($id, $ical) = $self->icalfile('locations-conference');

    my $event = $self->putandget_vevent($id, $ical);
    my $virtualLocations = $event->{virtualLocations};
    $self->assert_num_equals(5, scalar (values %{$virtualLocations}));

    my $loc1 = $virtualLocations->{loc1};
    $self->assert_cmp_deeply(
        superhashof({
            name => 'Moderator dial-in',
            uri => 'tel:+123451',
            features => {
                phone => JSON::true,
                moderator => JSON::true,
            }
        }),
        $loc1
    );

    my $loc2 = $virtualLocations->{loc2};
    $self->assert_cmp_deeply(
        superhashof({
            name => 'Chat room',
            uri => 'xmpp:chat123@conference.example.com',
            features => {
                chat => JSON::true,
            }
        }),
        $loc2
    );

    my $loc3 = $virtualLocations->{loc3};
    $self->assert_cmp_deeply(
        superhashof({
            name => 'Bad Feature 1',
            uri => 'https://example.com',
        }),
        $loc3
    );

    my $loc4 = $virtualLocations->{loc4};
    $self->assert_cmp_deeply(
        superhashof({
            name => 'Bad Feature 2',
            uri => 'https://example.com',
        }),
        $loc4
    );

    my $loc5 = $virtualLocations->{loc5};
    $self->assert_cmp_deeply(
        superhashof({
            name => 'Bad Feature 3',
            uri => 'https://example.com',
            features => {
                audio => JSON::true,
                video => JSON::true,
            }
        }),
        $loc5
    );
}
