This repository has been archived on 2024-10-29. You can view files and clone it, but cannot push or open issues or pull requests.
api/generators/service/service.test.ts.hbs

38 lines
954 B
Handlebars
Raw Normal View History

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}}
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
await t.test('succeeds', async (t) => {
2021-10-24 04:18:18 +02:00
{{#if shouldBeAuthenticated}}
const { accessToken } = await authenticateUserTest()
2021-10-24 04:18:18 +02:00
{{/if}}
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()
t.equal(response.statusCode, 200)
2021-10-24 04:18:18 +02:00
})
})