File: z_02_disco.t

package info (click to toggle)
libanyevent-xmpp-perl 0.55-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 784 kB
  • ctags: 553
  • sloc: perl: 8,004; makefile: 13
file content (61 lines) | stat: -rw-r--r-- 1,478 bytes parent folder | download | duplicates (6)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!perl

use strict;
use Test::More;
use AnyEvent::XMPP::TestClient;
use AnyEvent::XMPP::IM::Message;
use AnyEvent::XMPP::Util qw/bare_jid/;

my $cl =
   AnyEvent::XMPP::TestClient->new_or_exit (
      tests => 3, two_accounts => 1, finish_count => 2
   );
my $C = $cl->client;
my $disco = $cl->instance_ext ('AnyEvent::XMPP::Ext::Disco');
$disco->set_identity (client => bot => "net xmpp2 test");

my $disco_error = '';

$C->reg_cb (
   two_accounts_ready => sub {
      my ($C) = @_;

      $disco->request_info ($cl->{acc}->connection, $cl->{jid2}, undef, sub {
         my ($disco, $info, $error) = @_;

         if ($error) {
            $disco_error = $error->string;

         } else {
            my (@ids) = $info->identities ();
            ok (
               (grep {
                  $_->{category} eq 'client'
                  && $_->{type} eq 'bot'
                  && $_->{name} eq 'net xmpp2 test'
               } @ids),
               "has bot identity"
            );

            ok (
               (grep {
                  $_->{category} eq 'client'
                  && $_->{type} eq 'console'
                  && $_->{name} eq 'net xmpp2 test'
               } @ids),
               "has default identity"
            );

            ok (
               (grep { 'jabber:x:data' eq $_ } keys %{$info->features}),
               "has data forms feature"
            );
         }
         $cl->finish;
      });

      $cl->finish;
   }
);

$cl->wait;