Add more tests for SiteRoutes
This commit is contained in:
parent
25574903ba
commit
04b3a7ca90
@ -51,4 +51,26 @@ describe('team', () => {
|
||||
|
||||
})
|
||||
|
||||
describe('GET /teams/:teamId/sites/:id', () => {
|
||||
it('fetches a site belonging to a team', async () => {
|
||||
const site = await createSite(t, 'test.example.com')
|
||||
const response = await t.get('/teams/:teamId/sites/:id', {
|
||||
teamId: site.teamId,
|
||||
id: site.id,
|
||||
})
|
||||
.expect(200)
|
||||
expect(response.body!.id).toEqual(site.id)
|
||||
})
|
||||
})
|
||||
|
||||
describe('GET /teams/:teamId/sites', () => {
|
||||
it('fetches all sites belonging to a team', async () => {
|
||||
const site = await createSite(t, 'test.example.com')
|
||||
const response = await t.get('/teams/:teamId/sites', {
|
||||
teamId: site.teamId,
|
||||
})
|
||||
expect(response.body.map(s => s.id)).toContain(site.id)
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
@ -32,6 +32,7 @@ export class SiteRoutes extends BaseRoute<IAPIDef> {
|
||||
|
||||
t.use(ensureLoggedInApi)
|
||||
|
||||
// TODO do not use this one without teamId
|
||||
t.get('/my/sites', async req => {
|
||||
return this.siteService.findByUser(req.user!.id)
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user