### ----------------------------------------------------
### -- Humming-Bird
### -- Licenses: MIT
### -- Authors: Rawley Fowler
### -- File: t/01-basic.rakutest
### ----------------------------------------------------
use v6;
use lib 'lib';
use strict;
use Test;
use Humming-Bird::Core;
use Humming-Bird::Glue;
use lib 't/lib';
use Humming-Bird::Test;

plan 8;

my &cb = sub (Request $request, Response $response --> Response) {
    $response.html('Hello World');
}

get('/', &cb);

is routes{'/'}{GET}.path, '/', 'Is route path OK?';
is routes{'/'}{GET}.callback.raku, &cb.raku, 'Is callback OK?';

my @context = get-context(path => '/', method => GET, version => 'HTTP/1.1');
is routes{'/'}{GET}(|@context).header('Content-Type'), 'text/html', 'Is response header content type OK?';
is routes{'/'}{GET}(|@context).body.decode, 'Hello World', 'Is response body OK?';

post('/', &cb);
is routes{'/'}{POST}.path, '/', 'Is route path OK?';
is routes{'/'}{POST}.callback.raku, &cb.raku, 'Is callback OK?';

@context = get-context(path => '/', method => POST, version => 'HTTP/1.1');
is routes{'/'}{POST}(|@context).header('Content-Type'), 'text/html', 'Is response header content type OK?';
is routes{'/'}{POST}(|@context).body.decode, 'Hello World', 'Is response body OK?';

# vim: expandtab shiftwidth=4


