71 lines
1.9 KiB
Plaintext
71 lines
1.9 KiB
Plaintext
{
|
|
"Test for library function": {
|
|
"scope": "typescript",
|
|
"isFileTemplate": true,
|
|
"prefix": "testLib",
|
|
"body": [
|
|
"import { describe, expect, it } from \"bun:test\";",
|
|
"",
|
|
"import { $1 } from \"./$1\";",
|
|
"",
|
|
"describe(\"$1\", () => {",
|
|
" it(\"$2\", () => {",
|
|
" });",
|
|
"});",
|
|
"",
|
|
],
|
|
"description": "Test for library function",
|
|
},
|
|
"Test for route": {
|
|
"prefix": "testRoute",
|
|
"body": [
|
|
"import { describe, expect, it } from \"bun:test\";",
|
|
"",
|
|
"import app from \"~/index\";",
|
|
"import { server } from \"~/mocks\";",
|
|
"",
|
|
"server.listen();",
|
|
"",
|
|
"describe(\"requests the /$1 route\", () => {",
|
|
" it(\"should succeed\", async () => {",
|
|
" const res = await app.request(\"/$1\");",
|
|
"",
|
|
" expect(res.json()).resolves.toEqual({ success: true });",
|
|
" expect(res.status).toBe(200);",
|
|
" });",
|
|
"});",
|
|
"",
|
|
],
|
|
"description": "Test for route",
|
|
},
|
|
"Test for route with DB": {
|
|
"prefix": "testRouteDB",
|
|
"body": [
|
|
"import { beforeEach, describe, expect, it } from \"bun:test\";",
|
|
"",
|
|
"import app from \"~/index\";",
|
|
"import { server } from \"~/mocks\";",
|
|
"import { resetDb } from \"~/models/db\";",
|
|
"import { getTestDb } from \"~/libs/test/getTestDb\";",
|
|
"",
|
|
"server.listen();",
|
|
"",
|
|
"describe(\"requests the /$1 route\", () => {",
|
|
" const db = getTestDb();",
|
|
"",
|
|
" beforeEach(async () => {",
|
|
" await resetDb();",
|
|
" });",
|
|
"",
|
|
" it(\"should succeed\", async () => {",
|
|
" const res = await app.request(\"/$1\");",
|
|
"",
|
|
" expect(res.json()).resolves.toEqual({ success: true });",
|
|
" expect(res.status).toBe(200); ",
|
|
" });",
|
|
"});",
|
|
],
|
|
"description": "Test for route with DB",
|
|
},
|
|
}
|