-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix issues that occured when users deleted their accounts and ad…
…d delete-account.spec.ts tests in the backend
- Loading branch information
Showing
3 changed files
with
44 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { TestManager } from '../../utils/test-manager'; | ||
import { HttpStatus } from '@nestjs/common'; | ||
import { usersContract } from '@shared/contracts/users.contract'; | ||
import { ROLES } from '@shared/entities/users/roles.enum'; | ||
|
||
describe('Delete Account', () => { | ||
let testManager: TestManager; | ||
|
||
beforeAll(async () => { | ||
testManager = await TestManager.createTestManager(); | ||
}); | ||
|
||
afterEach(async () => { | ||
await testManager.clearDatabase(); | ||
}); | ||
|
||
afterAll(async () => { | ||
await testManager.close(); | ||
}); | ||
|
||
test("An existing user should be able to delete it's account", async () => { | ||
// Given a user exists with valid credentials | ||
const user = await testManager.mocks().createUser({ | ||
role: ROLES.PARTNER, | ||
email: '[email protected]', | ||
isActive: true, | ||
password: '12345678', | ||
}); | ||
|
||
const { jwtToken } = await testManager.logUserIn(user); | ||
|
||
// And the user tries to sign in with valid credentials | ||
const response = await testManager | ||
.request() | ||
.delete(usersContract.deleteMe.path) | ||
.set('Authorization', `Bearer ${jwtToken}`) | ||
.send(); | ||
|
||
// We should get back OK response and an access token | ||
expect(response.status).toBe(HttpStatus.OK); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters