-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
jmap_contatc.c: handle ordered N/ADR with PHONETICs
- Loading branch information
1 parent
603e141
commit 69d055a
Showing
2 changed files
with
112 additions
and
9 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
cassandane/tiny-tests/JMAPContacts/card-get-ordered-phonetics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!perl | ||
use Cassandane::Tiny; | ||
use utf8; | ||
|
||
sub test_card_get_ordered_phonetics | ||
:min_version_3_9 :needs_component_jmap | ||
{ | ||
my ($self) = @_; | ||
my $jmap = $self->{jmap}; | ||
|
||
my $service = $self->{instance}->get_service("http"); | ||
$ENV{DEBUGDAV} = 1; | ||
my $carddav = Net::CardDAVTalk->new( | ||
user => 'cassandane', | ||
password => 'pass', | ||
host => $service->host(), | ||
port => $service->port(), | ||
scheme => 'http', | ||
url => '/', | ||
expandurl => 1, | ||
); | ||
|
||
my $id = 'ae2640cc-234a-4dd9-95cc-3106258445b9'; | ||
my $href = "Default/$id.vcf"; | ||
my $card = <<EOF; | ||
BEGIN:VCARD | ||
VERSION:4.0 | ||
UID:$id | ||
N;ALTID=n1;PHONETIC=IPA:/smɪθ/;/d͡ʒɑn/;;;;; | ||
N;JSCOMPS=";1;0";ALTID=n1:Smith;John;;;;; | ||
FN;DERIVED=TRUE:John Smith | ||
CREATED:20230824T143619Z | ||
END:VCARD | ||
EOF | ||
|
||
$card =~ s/\r?\n/\r\n/gs; | ||
$carddav->Request('PUT', $href, $card, 'Content-Type' => 'text/vcard'); | ||
|
||
my $res = $jmap->CallMethods([ | ||
['ContactCard/get', { | ||
}, 'R1'] | ||
]); | ||
|
||
my $want_jscard = { | ||
'@type' => 'Card', | ||
version => '1.0', | ||
addressBookId => 'Default', | ||
'cyrusimap.org:href' => $carddav->fullpath() . $href, | ||
id => $id, | ||
uid => $id, | ||
created => '2023-08-24T14:36:19Z', | ||
vCardProps => [ | ||
[ 'version', {}, 'text', '4.0' ] | ||
], | ||
name => { | ||
phoneticSystem => 'ipa', | ||
isOrdered => JSON::true, | ||
components => [ | ||
{ kind => 'given', value => 'John' , phonetic => "/d͡ʒɑn/" }, | ||
{ kind => 'surname', value => 'Smith', phonetic => "/smɪθ/" } | ||
] | ||
}, | ||
}; | ||
|
||
my $have_jscard = $res->[0][1]{list}[0]; | ||
|
||
# Delete generated fields | ||
delete $have_jscard->{blobId}; | ||
delete $have_jscard->{'cyrusimap.org:blobId'}; | ||
delete $have_jscard->{'cyrusimap.org:size'}; | ||
|
||
# Normalize and compare cards | ||
normalize_jscard($want_jscard); | ||
normalize_jscard($have_jscard); | ||
|
||
warn Dumper($want_jscard); | ||
warn Dumper($have_jscard); | ||
$self->assert_deep_equals($want_jscard, $have_jscard); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters