Removed redundant file and fixed user updat e+ added tests
This commit is contained in:
parent
bad60c85e7
commit
9affdbf08e
4 changed files with 115 additions and 104 deletions
84
t/api/user.t
84
t/api/user.t
|
@ -20,7 +20,7 @@ $schema->resultset('AccountToken')->create({
|
|||
$framework->register_customer({
|
||||
'token' => $account_token,
|
||||
'full_name' => 'Test User',
|
||||
'display_name' => 'Test User',
|
||||
'display_name' => 'Testing User',
|
||||
'email' => $email,
|
||||
'postcode' => 'LA1 1AA',
|
||||
'password' => $password,
|
||||
|
@ -34,7 +34,7 @@ my $session_key = $framework->login({
|
|||
|
||||
my $json_no_date = { session_key => $session_key };
|
||||
$t->post_ok('/api/user/day', json => $json_no_date)
|
||||
->status_is(200)
|
||||
->status_is(200)->or($framework->dump_error)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
my $json_invalid_date = {
|
||||
|
@ -54,4 +54,84 @@ $t->post_ok('/api/user/day', json => $json_valid_date)
|
|||
->status_is(200)->or($framework->dump_error)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
$t->post_ok('/api/user', json => { session_key => $session_key })
|
||||
->status_is(200)->or($framework->dump_error)
|
||||
->json_is({
|
||||
success => Mojo::JSON->true,
|
||||
full_name => 'Test User',
|
||||
display_name => 'Testing User',
|
||||
email => $email,
|
||||
postcode => 'LA1 1AA',
|
||||
});
|
||||
|
||||
#with wrong password
|
||||
$t->post_ok('/api/user/account', json => {
|
||||
session_key => $session_key,
|
||||
full_name => 'Test User 2',
|
||||
display_name => 'Testing User 2',
|
||||
email => 'test50@example.com',
|
||||
postcode => 'LA1 1AB',
|
||||
password => 'abc12431',
|
||||
})
|
||||
->status_is(401)->or($framework->dump_error)
|
||||
->json_is({
|
||||
success => Mojo::JSON->false,
|
||||
message => 'password is invalid.',
|
||||
});
|
||||
|
||||
# With valid details
|
||||
$t->post_ok('/api/user/account', json => {
|
||||
session_key => $session_key,
|
||||
full_name => 'Test User 2',
|
||||
display_name => 'Testing User 2',
|
||||
email => 'test50@example.com',
|
||||
postcode => 'LA1 1AB',
|
||||
password => $password,
|
||||
})
|
||||
->status_is(200)->or($framework->dump_error)
|
||||
->json_is({
|
||||
success => Mojo::JSON->true,
|
||||
message => 'Edited Account Successfully',
|
||||
});
|
||||
|
||||
$t->post_ok('/api/user', json => { session_key => $session_key })
|
||||
->status_is(200)->or($framework->dump_error)
|
||||
->json_is({
|
||||
success => Mojo::JSON->true,
|
||||
full_name => 'Test User 2',
|
||||
display_name => 'Testing User 2',
|
||||
email => 'test50@example.com',
|
||||
postcode => 'LA1 1AB',
|
||||
});
|
||||
|
||||
$t->post_ok('/api/user/account', json => {
|
||||
session_key => $session_key,
|
||||
full_name => 'Test User 3',
|
||||
display_name => 'Testing User 3',
|
||||
email => 'test60@example.com',
|
||||
postcode => 'LA1 1AD',
|
||||
password => $password,
|
||||
new_password => 'abc124',
|
||||
})
|
||||
->status_is(200)->or($framework->dump_error)
|
||||
->json_is({
|
||||
success => Mojo::JSON->true,
|
||||
message => 'Edited Account Successfully',
|
||||
});
|
||||
|
||||
$t->post_ok('/api/user', json => { session_key => $session_key })
|
||||
->status_is(200)->or($framework->dump_error)
|
||||
->json_is({
|
||||
success => Mojo::JSON->true,
|
||||
full_name => 'Test User 3',
|
||||
display_name => 'Testing User 3',
|
||||
email => 'test60@example.com',
|
||||
postcode => 'LA1 1AD',
|
||||
});
|
||||
|
||||
$session_key = $framework->login({
|
||||
email => 'test60@example.com',
|
||||
password => 'abc124',
|
||||
});
|
||||
|
||||
done_testing;
|
||||
|
|
Reference in a new issue