feat: usage of ESM modules imports (instead of CommonJS) (#5)

Replace `jest` with `tap`.
This commit is contained in:
Divlo
2022-03-20 11:49:27 +01:00
committed by GitHub
parent 91a0e2a76f
commit 19b6f96ecf
70 changed files with 8017 additions and 6318 deletions

View File

@ -1,5 +1,5 @@
/** @type {import('node-plop').PlopGeneratorConfig} */
exports.serviceGenerator = {
export const serviceGenerator = {
description: 'REST API endpoint',
prompts: [
{

View File

@ -1,15 +1,26 @@
import tap from 'tap'
import sinon from 'sinon'
import { application } from 'application.js'
{{#if shouldBeAuthenticated}}
import { authenticateUserTest } from '__test__/utils/authenticateUserTest.js'
{{/if}}
import { prismaMock } from '__test__/setup.js'
import prisma from 'tools/database/prisma.js'
describe('{{httpMethod}} {{url}}', () => {
it('succeeds', async () => {
// prismaMock.service.findUnique.mockResolvedValue(null)
await tap.test('{{httpMethod}} {{url}}', async (t) => {
t.afterEach(() => {
sinon.restore()
})
await t.test('succeeds', async (t) => {
{{#if shouldBeAuthenticated}}
const { accessToken, user } = await authenticateUserTest()
const { accessToken } = await authenticateUserTest()
{{/if}}
sinon.stub(prisma, 'channel').value({
findFirst: async () => {
return null
}
})
const response = await application.inject({
method: '{{httpMethod}}',
url: '{{url}}',
@ -21,6 +32,6 @@ describe('{{httpMethod}} {{url}}', () => {
payload: {}
})
// const responseJson = response.json()
expect(response.statusCode).toEqual(200)
t.equal(response.statusCode, 200)
})
})