This repository has been archived on 2023-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
Foodloop-Server/t/api/v1/supplier/location.t
2017-09-27 18:01:06 +01:00

60 lines
1.3 KiB
Perl

use Mojo::Base -strict;
use FindBin qw/ $Bin /;
use Test::More;
use Mojo::JSON;
use Test::Pear::LocalLoop;
use DateTime;
my $framework = Test::Pear::LocalLoop->new(
etc_dir => "$Bin/../../../etc",
);
$framework->install_fixtures('full');
my $t = $framework->framework;
my $schema = $t->app->schema;
my $session_key = $framework->login({
email => 'org1@example.com',
password => 'abc123',
});
$t->post_ok('/api/upload' => json => {
transaction_value => 10,
transaction_type => 1,
purchase_time => "2017-08-14T11:29:07.965+01:00",
organisation_id => 2,
session_key => $session_key,
})
->status_is(200)
->json_is('/success', Mojo::JSON->true);
# Rough area around Lancaster
$t->post_ok('/api/v1/supplier/location' => json => {
session_key => $session_key,
north_east => {
latitude => 54.077665,
longitude => -2.761860,
},
south_west => {
latitude => 54.013361,
longitude => -2.857647,
},
})
->status_is(200)->or($framework->dump_error)
->json_is('/success', Mojo::JSON->true)
->json_is('/suppliers', [
{
name => 'Test Org 2',
latitude => 54.04679,
longitude => -2.7963,
},
])
->json_is('/self', {
latitude => 54.04725,
longitude => -2.79611,
});
done_testing;