Skip to content

Commit

Permalink
added tests for embedded applications with WebSockets
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Dec 3, 2014
1 parent 307cddd commit 6387b6b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions t/mojolicious/embedded_lite_app.t
Expand Up @@ -202,6 +202,12 @@ $t->get_ok('/x/1/template/menubar')->status_is(200)
# Missing template from myapp.pl
$t->get_ok('/x/1/template/does_not_exist')->status_is(404);

# Embedded WebSocket
$t->websocket_ok('/x/1/url_for')->send_ok('ws_test')
->message_ok->message_like(qr!^ws://localhost:\d+/x/1/url_for$!)
->send_ok('index')->message_ok->message_like(qr!^http://localhost:\d+/x/1$!)
->finish_ok;

# Template from myapp.pl with unicode prefix
$t->get_ok('/x/♥/')->status_is(200)->content_is(<<'EOF');
myapp
Expand Down
10 changes: 10 additions & 0 deletions t/mojolicious/external/myapp.pl
Expand Up @@ -53,6 +53,16 @@

get '/template/:template';

websocket '/url_for' => sub {
my $c = shift;
$c->on(
message => sub {
my ($c, $msg) = @_;
$c->send($c->url_for($msg)->to_abs);
}
);
} => 'ws_test';

app->start;
__DATA__
Expand Down

0 comments on commit 6387b6b

Please sign in to comment.