X-Git-Url: http://erislabs.net/gitweb/?p=libwww-opensearch-perl.git;a=blobdiff_plain;f=t%2F10-description.t;fp=t%2F10-description.t;h=784face2ea4d9dafe8d45dcd15f1c39d95c76bff;hp=0000000000000000000000000000000000000000;hb=ec50391b25e981b1b9bae8e42e03c0fc9c218845;hpb=3bea9ee9d57430b70d78dc4bed903b395bb4356a
diff --git a/t/10-description.t b/t/10-description.t
new file mode 100644
index 0000000..784face
--- /dev/null
+++ b/t/10-description.t
@@ -0,0 +1,138 @@
+use strict;
+use warnings;
+
+use Test::More tests => 38;
+
+use_ok( 'WWW::OpenSearch::Description' );
+
+# simple 1.1 OSD
+{
+ my $description = q(
+
+ Web Search
+ Use Example.com to search the Web.
+ example web
+ admin@example.com
+
+
+);
+
+ my $osd = WWW::OpenSearch::Description->new( $description );
+ isa_ok( $osd, 'WWW::OpenSearch::Description' );
+ is( $osd->shortname, 'Web Search' );
+ ok( !defined $osd->longname );
+ is( $osd->description, 'Use Example.com to search the Web.' );
+ is( $osd->tags, 'example web' );
+ is( $osd->contact, 'admin@example.com' );
+
+ # count the urls
+ is( $osd->urls, 1 );
+}
+
+# complex 1.1 OSD
+{
+ my $description = q(
+
+ Web Search
+ Use Example.com to search the Web.
+ example web
+ admin@example.com
+
+
+
+
+
+
+
+
+ Example.com Web Search
+ http://example.com/websearch.png
+ http://example.com/websearch.ico
+
+ Example.com Development Team
+
+ Search data © 2005, Example.com, Inc., All Rights Reserved
+
+ open
+ false
+ en-us
+ UTF-8
+ UTF-8
+
+);
+
+ my $osd = WWW::OpenSearch::Description->new( $description );
+ isa_ok( $osd, 'WWW::OpenSearch::Description' );
+ is( $osd->shortname, 'Web Search' );
+ is( $osd->longname, 'Example.com Web Search' );
+ is( $osd->description, 'Use Example.com to search the Web.' );
+ is( $osd->tags, 'example web' );
+ is( $osd->contact, 'admin@example.com' );
+ is( $osd->developer, 'Example.com Development Team' );
+ is( $osd->attribution, '
+ Search data © 2005, Example.com, Inc., All Rights Reserved
+ ' );
+ is( $osd->inputencoding, 'UTF-8' );
+ is( $osd->outputencoding, 'UTF-8' );
+ is( $osd->language, 'en-us' );
+ is( $osd->adultcontent, 'false' );
+ is( $osd->syndicationright, 'open' );
+
+ TODO: {
+ local $TODO = 'Test Query and Image';
+
+ is( $osd->query, undef );
+ is( $osd->image, undef );
+ };
+
+ # count the urls
+ is( $osd->urls, 3 );
+}
+
+# 1.0 OSD
+{
+ my $description = q(
+
+ http://www.unto.net/aws?q={searchTerms}&searchindex=Electronics
+ &flavor=osrss&itempage={startPage}
+ http://a9.com/-/spec/opensearchrss/1.0/
+ Electronics
+ Amazon Electronics
+ Search for electronics on Amazon.com.
+ amazon electronics
+ http://www.unto.net/search/amazon_electronics.gif
+ ipod
+ DeWitt Clinton
+ dewitt@unto.net
+ Product and search data © 2005, Amazon, Inc.,
+ All Rights Reserved
+ open
+ false
+
+);
+
+ my $osd = WWW::OpenSearch::Description->new( $description );
+ isa_ok( $osd, 'WWW::OpenSearch::Description' );
+ is( $osd->shortname, 'Electronics' );
+ is( $osd->longname, 'Amazon Electronics' );
+ is( $osd->description, 'Search for electronics on Amazon.com.' );
+ is( $osd->tags, 'amazon electronics' );
+ is( $osd->contact, 'dewitt@unto.net' );
+ is( $osd->format, 'http://a9.com/-/spec/opensearchrss/1.0/' );
+ is( $osd->image, 'http://www.unto.net/search/amazon_electronics.gif' );
+ is( $osd->samplesearch, 'ipod' );
+ is( $osd->developer, 'DeWitt Clinton' );
+ is( $osd->attribution, 'Product and search data © 2005, Amazon, Inc.,
+ All Rights Reserved' );
+ is( $osd->syndicationright, 'open' );
+ is( $osd->adultcontent, 'false' );
+
+ # count the urls
+ is( $osd->urls, 1 );
+}
+