Skip to content

Commit

Permalink
Update middleware.test.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
aelassas committed Sep 3, 2024
1 parent 8b74f01 commit 237bc78
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions api/tests/middleware.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ describe('GET /api/user/:id', () => {
.set('Cookie', cookie)
expect(res.statusCode).toBe(200)
expect(res.body.email).toBe(USER_EMAIL)

// Not allowed by CORS
res = await request(app)
.post(`/api/sign-in/${bookcarsTypes.AppType.Backend}`)
.set('Origin', 'http://unknow/')
.send(payload)
expect(res.statusCode).toBe(500)
})
})

Expand All @@ -84,12 +91,24 @@ describe('GET /api/user/:id', () => {
.send(payload)
expect(res.statusCode).toBe(200)

res = await request(app)
.post(`/api/sign-in/${bookcarsTypes.AppType.Frontend}`)
.send(payload)
expect(res.statusCode).toBe(200)

res = await request(app)
.get(`/api/user/${USER_ID}`)
.set('Origin', env.FRONTEND_HOST)
.set('Cookie', cookie)
expect(res.statusCode).toBe(200)
expect(res.body.email).toBe(USER_EMAIL)

// Not allowed by CORS
res = await request(app)
.post(`/api/sign-in/${bookcarsTypes.AppType.Frontend}`)
.set('Origin', 'http://unknow/')
.send(payload)
expect(res.statusCode).toBe(500)
})
})

Expand Down

0 comments on commit 237bc78

Please sign in to comment.