25 lines
744 B
Handlebars
25 lines
744 B
Handlebars
import { test } from '@japa/runner'
|
|
import db from '@adonisjs/lucid/services/db'
|
|
|
|
test.group('API /api/{{snakeCaseName}}', (group) => {
|
|
group.each.setup(async () => {
|
|
await db.beginGlobalTransaction()
|
|
return () => db.rollbackGlobalTransaction()
|
|
})
|
|
|
|
test('GET /api/{{snakeCaseName}} -> list', async ({ client }) => {
|
|
const res = await client.get('/api/{{snakeCaseName}}')
|
|
res.assertStatus(200)
|
|
})
|
|
|
|
test('POST /api/{{snakeCaseName}} -> create', async ({ client }) => {
|
|
const payload = {
|
|
{{#each createFields}}
|
|
{{column_name}}: {{{sampleValue}}}{{#unless @last}},{{/unless}}
|
|
{{/each}}
|
|
}
|
|
const res = await client.post('/api/{{snakeCaseName}}').json(payload)
|
|
res.assertStatus(201)
|
|
})
|
|
})
|