File: 04-formats.t

package info (click to toggle)
libtext-vcard-perl 2.10-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 176 kB
  • sloc: perl: 836; makefile: 4
file content (36 lines) | stat: -rw-r--r-- 1,090 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/perl -w

use strict;

use lib qw(./lib);

use Test::More  tests => 17;
# Check we can load module
use Data::Dumper;
BEGIN { use_ok( 'Text::vCard::Addressbook' ); }

my @card_types = qw(evolution.vcf apple_2.1_unicode.vcf apple_version3.vcf);

foreach my $card_type (@card_types) {
	ok($card_type,"Running from $card_type");
	my $adbk = Text::vCard::Addressbook->new({ source_file => "t/$card_type" });
	isa_ok($adbk,'Text::vCard::Addressbook');
	my $vcards = $adbk->vcards();
	
	is(scalar(@{$vcards}),1,"$card_type has 1 vcards as expected");
	my $vcard = $vcards->[0];
	is($vcard->get('fn')->[0]->value(),'T-firstname T-surname',"$card_type has fn data correct");
#	print Dumper($vcard);
	my $t = $vcard->get({
		'node_type' => 'tel',
		'types' => 'home',
	});
	is($t->[0]->value(),'020 666 6666','got expected phone number');
}

my $adbk = Text::vCard::Addressbook->new({ source_file => "t/notes.vcf" });
my $vcards = $adbk->vcards();
my $note = $vcards->[0]->note;
is($note,'@prefix nasty <note>\; with \; added into it and\n@prefix del: \n"\; ]]\;\n]\;\n.','Got note ok');