test/test_vcard.rb in vpim-0.619 vs test/test_vcard.rb in vpim-0.658
- old
+ new
@@ -838,7 +838,136 @@
utf_name_test(le(bom+dat.downcase))
utf_name_test(le(dat))
utf_name_test(le(dat.downcase))
end
+ # Broken output from Highrise. Report to support@highrisehq.com
+ def test_highrises_invalid_google_talk_field
+ c = <<'__'
+BEGIN:VCARD
+VERSION:3.0
+REV:20080409T095515Z
+X-YAHOO;TYPE=HOME:yahoo.john
+X-GOOGLE TALK;TYPE=WORK:gtalk.john
+X-SAMETIME;TYPE=WORK:sametime.john
+X-SKYPE;TYPE=WORK:skype.john
+X-MSN;TYPE=WORK:msn.john
+X-JABBER;TYPE=WORK:jabber.john
+N:Doe;John;;;
+ADR;TYPE=WORK:;;456 Grandview Building\, Wide Street;San Diego;CA;90204;
+ United States
+ADR;TYPE=HOME:;;123 Sweet Home\, Narrow Street;New York;NY;91102;United
+ States
+URL;TYPE=OTHER:http\://www.homepage.com
+URL;TYPE=HOME:http\://www.home.com
+URL;TYPE=WORK:http\://www.work.com
+URL;TYPE=OTHER:http\://www.other.com
+URL;TYPE=OTHER:http\://www.custom.com
+ORG:John Doe & Partners Limited;;
+TEL;TYPE=WORK:11111111
+TEL;TYPE=CELL:22222222
+TEL;TYPE=HOME:33333333
+TEL;TYPE=OTHER:44444444
+TEL;TYPE=FAX:55555555
+TEL;TYPE=FAX:66666666
+TEL;TYPE=PAGER:77777777
+TEL;TYPE=OTHER:88888888
+TEL;TYPE=OTHER:99999999
+UID:cc548e11-569e-3bf5-a9aa-722de4571f4a
+X-ICQ;TYPE=HOME:icq.john
+EMAIL;TYPE=WORK,INTERNET:john.doe@work.com
+EMAIL;TYPE=HOME,INTERNET:john.doe@home.com
+EMAIL;TYPE=OTHER,INTERNET:john.doe@other.com
+EMAIL;TYPE=OTHER,INTERNET:john.doe@custom.com
+TITLE:Sales Manager
+X-OTHER;TYPE=WORK:other.john
+X-AIM;TYPE=WORK:aim.john
+X-QQ;TYPE=WORK:qq.john
+FN:John Doe
+END:VCARD
+__
+
+ card = Vpim::Vcard.decode(c).first
+ assert_equal("Doe", card.name.family)
+ assert_equal("456 Grandview Building, Wide Street", card.address('work').street)
+ assert_equal("123 Sweet Home, Narrow Street", card.address('home').street)
+ assert_equal("John Doe & Partners Limited", card.org.first)
+ assert_equal("gtalk.john", card.value("x-google talk"))
+ assert_equal("http\\://www.homepage.com", card.url.uri)
+
+ end
+
+ def _test_gmail_vcard_export
+ # GOOGLE BUG - Whitespace before the LABEL field values is a broken
+ # line continuation.
+ # GOOGLE BUG - vCards are being exported with embedded "=" in them, so
+ # become unparseable.
+ c = <<'__'
+BEGIN:VCARD
+VERSION:3.0
+FN:Stepcase TestUser
+N:TestUser;Stepcase;;;
+EMAIL;TYPE=INTERNET:testuser@stepcase.com
+X-GTALK:gtalk.step
+X-AIM:aim.step
+X-YAHOO:yahoo.step
+X-MSN:msn.step
+X-ICQ:icq.step
+X-JABBER:jabber.step
+TEL;TYPE=FAX:44444444
+TEL;TYPE=PAGER:66666666
+TEL;TYPE=HOME:22222222
+TEL;TYPE=CELL:11111111
+TEL;TYPE=FAX:55555555
+TEL;TYPE=WORK:33333333
+LABEL;TYPE=HOME;ENCODING=QUOTED-PRINTABLE:123 Home, Home Street=0D=0A=
+Kowloon, N/A=0D=0A=
+Hong Kong
+LABEL;TYPE=HOME;ENCODING=QUOTED-PRINTABLE:321 Office, Work Road=0D=0A=
+Tsuen Wan NT=0D=0A=
+Hong Kong
+TITLE:CTO
+ORG:Stepcase.com
+NOTE:Stepcase test user is a robot.
+END:VCARD
+__
+ card = Vpim::Vcard.decode(c).first
+ assert_equal("123 Home, Home Street\r\n Kowloon, N/A\r\n Hong Kong", card.value("label"))
+ end
+
+ def test_title
+ title = "She Who Must Be Obeyed"
+ card = Vpim::Vcard::Maker.make2 do |m|
+ m.name do |n|
+ n.given = "Hilda"
+ n.family = "Rumpole"
+ end
+ m.title = title
+ end
+ assert_equal(title, card.title)
+ card = Vpim::Vcard.decode(card.encode).first
+ assert_equal(title, card.title)
+ end
+
+ def _test_org(*org)
+ card = Vpim::Vcard::Maker.make2 do |m|
+ m.name do |n|
+ n.given = "Hilda"
+ n.family = "Rumpole"
+ end
+ m.org = org
+ end
+ assert_equal(org, card.org)
+ card = Vpim::Vcard.decode(card.encode).first
+ assert_equal(org, card.org)
+ end
+
+ def test_org_single
+ _test_org("Megamix Corp.")
+ end
+
+ def test_org_multiple
+ _test_org("Megamix Corp.", "Marketing")
+ end
+
end