#!perl
use Cassandane::Tiny;

sub test_email_set_location
{
    my ($self) = @_;
    my $jmap = $self->{jmap};

    my $res = $jmap->CallMethods([
        ['Email/set', {
            create => {
                email1 => {
                    mailboxIds => {
                        '$inbox' => JSON::true,
                    },
                    from => [{ email => q{foo1@bar} }],
                    bodyStructure => {
                        location => "http://example.com/uri",
                        partId => '1',
                    },
                    bodyValues => {
                        "1" => {
                            value => "This is an email.",
                        },
                    },
                },
            },
        }, 'R1'],
        ['Email/get', {
            ids => ['#email1'],
            properties => [
                'bodyStructure',
            ],
            bodyProperties => [
                'location',
                'header:Content-Location',
            ],
        }, 'R2'],
    ]);
    $self->assert_str_equals(' http://example.com/uri',
        $res->[1][1]{list}[0]{bodyStructure}{'header:Content-Location'});
    $self->assert_str_equals('http://example.com/uri',
        $res->[1][1]{list}[0]{bodyStructure}{location});
}
