Dancer2-Plugin-JsonApi/t/registry.t

29 lines
579 B
Perl
Raw Normal View History

2023-10-31 16:16:36 +00:00
use Test2::V0;
use Dancer2::Plugin::JsonApi::Registry;
use experimental qw/ signatures /;
my $registry = Dancer2::Plugin::JsonApi::Registry->new;
$registry->add_type(
people => {
2023-10-31 19:54:28 +00:00
id => 'id',
links => {
self => sub ( $data, @ ) {
2023-10-31 20:29:48 +00:00
no warnings qw/ uninitialized /;
2023-10-31 19:54:28 +00:00
return "/peoples/$data->{id}";
}
2023-11-13 18:38:56 +00:00
}
}
);
2023-10-31 16:16:36 +00:00
2023-11-13 18:38:56 +00:00
isa_ok $registry->type('people') => 'Dancer2::Plugin::JsonApi::Schema';
2023-10-31 16:16:36 +00:00
2023-10-31 19:54:28 +00:00
like(
$registry->serialize( people => {} ),
2023-11-13 18:38:56 +00:00
{ jsonapi => { version => '1.0' } }
);
2023-10-31 16:16:36 +00:00
done_testing();