Skip to content

Commit

Permalink
Updating front and backend unit tests to increase coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Sik committed Aug 18, 2015
1 parent 0076c09 commit 38d331d
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 2 deletions.
13 changes: 13 additions & 0 deletions api/tests/integration/UserTest.php
Expand Up @@ -460,6 +460,19 @@ public function testResetPasswordMail()
$this->assertException('invalid', 401, 'UnauthorizedException');
}

public function testResetPasswordMailInvalidEmail()
{
$this->clearMessages();
$user = $this->createUser(['user_type' => 'guest']);
$token = $this->tokenFromUser($user);

$this->delete('/users/foo.bar.' . $user->email . '/password', [], [
'HTTP_AUTHORIZATION' => 'Bearer '.$token
]);

$this->assertResponseStatus(404);
}

public function testChangeEmail()
{
$this->clearMessages();
Expand Down
49 changes: 47 additions & 2 deletions app/src/common/services/user/userService.spec.ts
Expand Up @@ -83,9 +83,9 @@

});

describe('All users', () => {
describe('Retrieving User/Users', () => {

it ('should return all users', () => {
it('should return all users', () => {

let users = _.clone(fixtures.users); //get a new user copy

Expand All @@ -112,6 +112,34 @@

});

it('should be able to retrieve full info for one user', () => {

let user = _.clone(fixtures.user);

$httpBackend.expectGET('/api/users/' + user.userId).respond(200);

let userDetailsPromise = userService.getUser(user);

expect(userDetailsPromise).eventually.to.be.fulfilled;

$httpBackend.flush();

});

it('should return a new user created from user data', () => {

let userData = _.clone(fixtures.buildUser());

let user = userService.userFactory(userData);

expect(user).to.be.instanceOf(common.models.User);

expect(userData.email).to.equal(user.email);

expect(userData.userId).to.equal(user.userId);

});

});

describe('User Registration', () => {
Expand Down Expand Up @@ -222,6 +250,22 @@
$httpBackend.flush();
});

it('should reject the promise if a bogus user id is passed through', () => {

let user = _.clone(fixtures.user);
user.userId = 'bogus-user-id';

const emailToken = 'cf8a43a2646fd46c2081960ff1150a6b48d5ed062da3d59559af5030eea21548';

$httpBackend.expectPATCH('/api/users/' + user.userId).respond(422);

let emailConfirmationPromise = userService.confirmEmail(user, emailToken);

expect(emailConfirmationPromise).eventually.to.be.rejected;

$httpBackend.flush();
});

});

describe('Update Details', () => {
Expand Down Expand Up @@ -252,6 +296,7 @@
});

});

});


Expand Down

0 comments on commit 38d331d

Please sign in to comment.