mirror of
https://codeberg.org/JasterV/sentences-crud.git
synced 2026-04-26 18:10:05 +00:00
test auth
This commit is contained in:
parent
551e04da13
commit
d6c514328b
1 changed files with 20 additions and 0 deletions
|
|
@ -13,6 +13,15 @@ beforeAll(() => {
|
|||
|
||||
describe('Test sentences api', () => {
|
||||
|
||||
it('returns unauthorized if no auth provided', async () => {
|
||||
expect.assertions(1)
|
||||
const result = await request.get('/api/v1/sentences').expect(401)
|
||||
expect(result.body).toMatchObject({
|
||||
success: false,
|
||||
msg: 'Unauthorized'
|
||||
})
|
||||
})
|
||||
|
||||
it('can get sentence by Id', async () => {
|
||||
expect.assertions(1)
|
||||
const sentence = sentencesData['abc123']
|
||||
|
|
@ -25,4 +34,15 @@ describe('Test sentences api', () => {
|
|||
})
|
||||
});
|
||||
|
||||
it('returns error 404 if sentence not found', async () => {
|
||||
expect.assertions(1)
|
||||
const result = await request
|
||||
.get('/api/v1/sentences/patata')
|
||||
.set('Authorization', `Bearer ${mockConfig.secret}`)
|
||||
expect(result.body).toMatchObject({
|
||||
success: false,
|
||||
msg: 'Sentence with id patata not found'
|
||||
})
|
||||
})
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue