From 5a08739148c0103cbde65694bca384b78be76fee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrej=20Rama=C5=A1euski?= <andrej@x2.cz> Date: Tue, 1 Feb 2022 00:59:17 +0100 Subject: [PATCH] Test websocketu --- t/basic.t | 2 +- t/ws.t | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 t/ws.t diff --git a/t/basic.t b/t/basic.t index 1a5e0f2..5c374c2 100644 --- a/t/basic.t +++ b/t/basic.t @@ -4,7 +4,7 @@ use Test::More; use Test::Mojo; my $t = Test::Mojo->new('CF'); -$t->get_ok('/api.html')->status_is(200)->content_like(qr/CF Online/i); + $t->get_ok('/api.json')->status_is(200) ->json_is('/openapi' => '3.0.3') ->json_is('/info/title' => 'CF Online') diff --git a/t/ws.t b/t/ws.t new file mode 100644 index 0000000..94136a6 --- /dev/null +++ b/t/ws.t @@ -0,0 +1,17 @@ +use Mojo::Base -strict; + +use Test::More; +use Test::Mojo; + +my $t = Test::Mojo->new('CF'); + +# Test JSON web service +$t->websocket_ok('/ws') + ->send_ok({json => {event => 'KEEPALIVE'}}) + ->message_ok + ->json_message_is('/event' => 'online_users_updated') + ->json_message_has('/payload/all') + ->finish_ok; +; + +done_testing(); -- GitLab