Skip to content

Commit

Permalink
more WebSocket tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Apr 11, 2013
1 parent 506c99a commit 1b966c6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions t/mojolicious/websocket_lite_app.t
Expand Up @@ -191,7 +191,7 @@ $t->websocket_ok('/unicode')->send_ok('hello again')
->send_ok('and one ☃ more time')
->message_ok->message_is('♥: and one ☃ more time')->finish_ok;

# Binary frame and frame event
# Binary frame and events
my $bytes = b("I ♥ Mojolicious")->encode('UTF-16LE')->to_string;
$t->websocket_ok('/bytes');
my $binary;
Expand All @@ -201,11 +201,15 @@ $t->tx->on(
$binary++ if $frame->[4] == 2;
}
);
my $close;
$t->tx->on(finish => sub { shift; $close = [@_] });
$t->send_ok({binary => $bytes})->message_ok->message_is($bytes);
ok $binary, 'received binary frame';
$binary = undef;
$t->send_ok({text => $bytes})->message_ok->message_is($bytes)->finish_ok;
$t->send_ok({text => $bytes})->message_ok->message_is($bytes);
ok !$binary, 'received text frame';
$t->finish_ok(1000 => 'Have a nice day!');
is_deeply $close, [1000, 'Have a nice day!'], 'right status and message';

# Binary roundtrips
$t->websocket_ok('/bytes')->send_ok({binary => $bytes})
Expand Down

0 comments on commit 1b966c6

Please sign in to comment.