mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19:46 +00:00
test: split test into 2 test functions
This commit is contained in:
parent
edd9512b01
commit
76f91687bd
1 changed files with 26 additions and 4 deletions
|
|
@ -97,7 +97,7 @@ Deno.test('PUT /wallet must be successful', {
|
|||
]);
|
||||
});
|
||||
|
||||
Deno.test('PUT /wallet must NOT be successful', {
|
||||
Deno.test('PUT /wallet must NOT be successful: wrong request body/schema', {
|
||||
sanitizeOps: false, // postgres.js calls 'setTimeout' without calling 'clearTimeout'
|
||||
sanitizeResources: false, // postgres.js calls 'setTimeout' without calling 'clearTimeout'
|
||||
}, async () => {
|
||||
|
|
@ -130,10 +130,32 @@ Deno.test('PUT /wallet must NOT be successful', {
|
|||
|
||||
assertEquals(response.status, 400);
|
||||
assertObjectMatch(body, { error: 'Bad schema' });
|
||||
});
|
||||
|
||||
Deno.test('PUT /wallet must NOT be successful: wallet already exists', {
|
||||
sanitizeOps: false, // postgres.js calls 'setTimeout' without calling 'clearTimeout'
|
||||
sanitizeResources: false, // postgres.js calls 'setTimeout' without calling 'clearTimeout'
|
||||
}, async () => {
|
||||
await using db = await createTestDB();
|
||||
const store = db.store;
|
||||
|
||||
const sk = generateSecretKey();
|
||||
const signer = new NSecSigner(sk);
|
||||
|
||||
const app = new Hono<AppEnv>().use(
|
||||
async (c, next) => {
|
||||
c.set('signer', signer);
|
||||
await next();
|
||||
},
|
||||
async (c, next) => {
|
||||
c.set('store', store);
|
||||
await next();
|
||||
},
|
||||
).route('/', cashuApp);
|
||||
|
||||
await db.store.event(genEvent({ kind: 17375 }, sk));
|
||||
|
||||
const response2 = await app.request('/wallet', {
|
||||
const response = await app.request('/wallet', {
|
||||
method: 'PUT',
|
||||
headers: [['content-type', 'application/json']],
|
||||
body: JSON.stringify({
|
||||
|
|
@ -141,8 +163,8 @@ Deno.test('PUT /wallet must NOT be successful', {
|
|||
}),
|
||||
});
|
||||
|
||||
const body2 = await response2.json();
|
||||
const body2 = await response.json();
|
||||
|
||||
assertEquals(response2.status, 400);
|
||||
assertEquals(response.status, 400);
|
||||
assertEquals(body2, { error: 'You already have a wallet 😏' });
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue