Skip to content

Commit

Permalink
feat: add account unblock endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
apsantiso committed Jan 12, 2024
1 parent afe061f commit b7cd31a
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,30 @@ export class Auth {
);
}

/**
* Requests account unblock email
* @param email
* @returns {Promise<void>} Resolves when email is sent
*/
public requestUnblockAccount(email: string): Promise<void> {
return this.client.post(
'users/unblock-account',
{
email,
},
this.basicHeaders(),
);
}

/**
* Unblocks account with token
* @param token token sent by email
* @returns {Promise<void>} Resolves successfuly when account is unblocked
*/
public unblockAccount(token: string): Promise<void> {
return this.client.put('users/unblock-account', { token }, this.basicHeaders());
}

/**
* Tries to log in a user given its login details
* @param details
Expand Down
34 changes: 34 additions & 0 deletions test/auth/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,40 @@ describe('# auth service tests', () => {

});



describe('-> send email unblock account', () => {
it('Should call with right params & return values', async () => {
// Arrange
const callStub = sinon.stub(httpClient, 'post').resolves({});
const { client, headers } = clientAndHeaders();
const email = '[email protected]';

// Act
const body = await client.requestUnblockAccount(email);

// Assert
expect(callStub.firstCall.args).toEqual([`users/unblock-account`, { email }, headers]);
expect(body).toEqual({});
});
});

describe('-> unblock account', () => {
it('Should call with right params & return values', async () => {
// Arrange
const callStub = sinon.stub(httpClient, 'put').resolves({});
const { client, headers } = clientAndHeaders();
const token = 'token';

// Act
const body = await client.unblockAccount(token);

// Assert
expect(callStub.firstCall.args).toEqual([`users/unblock-account`, { token }, headers]);
expect(body).toEqual({});
});
});

});

function clientAndHeaders(
Expand Down

0 comments on commit b7cd31a

Please sign in to comment.