Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9c49cf4
commit 5499af3
Showing
24 changed files
with
307 additions
and
198 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,49 @@ | ||
import { UsersSchema } from '@api/users'; | ||
import { UsersSchema, ERoles } from '@api/users'; | ||
import { Body } from '@lib/mongoose'; | ||
import { superAgent } from '@test/index'; | ||
import { Constants, NetworkStatus } from '@core/helpers'; | ||
import { UserFixture } from '@test/fixture'; | ||
import { UserFixture as userFixture, getUri } from '@test/fixture'; | ||
import { AppUtils } from '@core/utils'; | ||
|
||
const ENDPOINT = `/api/${Constants.Endpoints.PORTAL}/login/${Constants.Endpoints.USERS}/`; | ||
const ENDPOINT = getUri(`${Constants.Endpoints.PORTAL}/login`); | ||
|
||
let user: UserFixture = null; | ||
const mockUser = { | ||
password: '123456789', | ||
username: 'portalLogin', | ||
email: 'portal@login.com', | ||
mobile: '0792807794', | ||
profile: null, | ||
role: ERoles.SUPERADMIN | ||
} as Body<UsersSchema>; | ||
let userFixture: userFixture = null; | ||
|
||
beforeAll(async () => { | ||
const body = { | ||
password: '123456789', | ||
username: 'portalLogin', | ||
email: 'portal@login.com', | ||
mobile: '0792807794' | ||
} as Body<UsersSchema>; | ||
const req = (await superAgent).post(ENDPOINT); | ||
const res = await req.send(body); | ||
user = res.body.data; | ||
const res = await req.send(mockUser); | ||
userFixture = res.body.data; | ||
}); | ||
|
||
describe('Login should fail if..', () => { | ||
it('`Request with non existing user`', async () => { | ||
const body = { | ||
password: '123456789', | ||
username: 'portalLogin' | ||
} as Body<UsersSchema>; | ||
const req = (await superAgent).post(ENDPOINT); | ||
const res = await req.send(body); | ||
const res = await req.send({ username: 'fakeUsername', password: 'fakePassword' }); | ||
expect(res.status).toBe(NetworkStatus.BAD_REQUEST); | ||
}); | ||
it('The Username was wrong', async () => { | ||
const req = (await superAgent).post(ENDPOINT); | ||
const res = await req.send(AppUtils.assignObject({}, mockUser, { username: 'fakeUsername' })); | ||
expect(res.status).toBe(NetworkStatus.BAD_REQUEST); | ||
}); | ||
it('The password was wrong', async () => { | ||
const req = (await superAgent).post(ENDPOINT); | ||
const res = await req.send(AppUtils.assignObject({}, mockUser, { password: 'fakePassword' })); | ||
expect(res.status).toBe(NetworkStatus.BAD_REQUEST); | ||
}); | ||
it.todo('The Username was wrong'); | ||
it.todo('The password was wrong'); | ||
it.todo('User trying to login with an old password'); | ||
it.todo('User has more than three session'); | ||
}); | ||
|
||
describe('Login should success when', () => { | ||
it.todo('Token is valid'); | ||
it.todo('Token has the appropriate schem'); | ||
it.todo('Token has the appropriate schema'); | ||
}); |
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,9 @@ | ||
import accountsService from '@api/accounts/accounts.service'; | ||
|
||
export class ProfileService { | ||
constructor() { } | ||
|
||
public update() { | ||
// accountsService.update(); | ||
} | ||
} |
Oops, something went wrong.