]> iEval git - zeal.git/blame_incremental - t/Zeal.t
Initial commit
[zeal.git] / t / Zeal.t
... / ...
CommitLineData
1#!/usr/bin/perl
2use strict;
3use warnings;
4
5use Test::More tests => 18;
6BEGIN { use_ok('Zeal') };
7
8note 'Working with t/ds/b.docset';
9my $ds = Zeal::Docset->new('t/ds/b.docset');
10is $ds->name, 'B', 'docset name is B';
11is $ds->id, 'b', 'docset id is b';
12is $ds->family, 'consonants', 'docset family is consonants';
13
14my @results = $ds->query('buil%');
15is @results, 2, 'query(buil%) returns two results';
16my $doc = $ds->query('building');
17is $doc->name, 'building', 'document name is building';
18is $doc->type, 'Word', 'document type is Word';
19like $doc->fetch, qr/^Dummy/, 'document HTML starts with "Dummy"';
20
21@results = sort {$a->name cmp $b->name} $ds->list;
22is @results, 2, 'docset contains two documents';
23is $results[0]->name, 'building', 'first result is "building"';
24
25note 'Working with all docsets in t/ds/';
26my $zeal = Zeal->new('t/ds/');
27my @sets = $zeal->sets;
28is @sets, 3, '3 docsets loaded';
29@results = $zeal->query('buil%');
30is @results, 2, '2 documents begin with "buil"';
31@results = $zeal->query('%t%');
32is @results, 3, '3 documents contain letter t';
33@results = $zeal->query('consonants:%t%');
34is @results, 2, '2 documents from the consonants family contain letter t';
35@results = $zeal->query('%t%', 'vowels');
36is @results, 1, '1 document from the vowels family contain letter t';
37
38note 'Working with t/ds/a.docset via Zeal and ->add';
39$zeal = Zeal->new;
40$zeal->add('t/ds/a.docset');
41@sets = $zeal->sets;
42is @sets, 1, '1 docset loaded';
43like $sets[0]->get('abou%'), qr/word/, 'HTML for abou% contains the word "word"';
44
45note 'Working with t/ds/a.docset via ZEAL_PATH';
46$ENV{ZEAL_PATH} = 't/ds/a.docset';
47$zeal = Zeal->new;
48is $zeal->query('about')->name, 'about';
This page took 0.022545 seconds and 4 git commands to generate.