2022-03-20 11:49:27 +01:00
|
|
|
import tap from 'tap'
|
|
|
|
import sinon from 'sinon'
|
|
|
|
|
2021-10-24 04:18:18 +02:00
|
|
|
import { application } from 'application.js'
|
|
|
|
{{#if shouldBeAuthenticated}}
|
|
|
|
import { authenticateUserTest } from '__test__/utils/authenticateUserTest.js'
|
|
|
|
{{/if}}
|
2022-03-20 11:49:27 +01:00
|
|
|
import prisma from 'tools/database/prisma.js'
|
|
|
|
|
|
|
|
await tap.test('{{httpMethod}} {{url}}', async (t) => {
|
|
|
|
t.afterEach(() => {
|
|
|
|
sinon.restore()
|
|
|
|
})
|
2021-10-24 04:18:18 +02:00
|
|
|
|
2022-03-20 11:49:27 +01:00
|
|
|
await t.test('succeeds', async (t) => {
|
2021-10-24 04:18:18 +02:00
|
|
|
{{#if shouldBeAuthenticated}}
|
2022-03-20 11:49:27 +01:00
|
|
|
const { accessToken } = await authenticateUserTest()
|
2021-10-24 04:18:18 +02:00
|
|
|
{{/if}}
|
2022-03-20 11:49:27 +01:00
|
|
|
sinon.stub(prisma, 'channel').value({
|
|
|
|
findFirst: async () => {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
})
|
2021-10-24 04:18:18 +02:00
|
|
|
const response = await application.inject({
|
|
|
|
method: '{{httpMethod}}',
|
|
|
|
url: '{{url}}',
|
|
|
|
{{#if shouldBeAuthenticated}}
|
|
|
|
headers: {
|
|
|
|
authorization: `Bearer ${accessToken}`
|
|
|
|
},
|
|
|
|
{{/if}}
|
|
|
|
payload: {}
|
|
|
|
})
|
|
|
|
// const responseJson = response.json()
|
2022-03-20 11:49:27 +01:00
|
|
|
t.equal(response.statusCode, 200)
|
2021-10-24 04:18:18 +02:00
|
|
|
})
|
|
|
|
})
|