From 061316876acdb0606b3d4ee9db7788728aec28e0 Mon Sep 17 00:00:00 2001 From: Satont Date: Thu, 24 Oct 2024 16:24:41 +0300 Subject: [PATCH] fix node tests for psql --- packages/psql/__tests__/node.ts | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/packages/psql/__tests__/node.ts b/packages/psql/__tests__/node.ts index 67c8ce89..386adae7 100644 --- a/packages/psql/__tests__/node.ts +++ b/packages/psql/__tests__/node.ts @@ -6,7 +6,7 @@ import pg from 'pg'; import { session } from 'grammy'; import * as utils from '@grammyjs/storage-utils'; -test.describe('Tests', () => { +test.describe('Tests', (it) => { const client = new pg.Client({ user: 'postgres', password: 'postgres', @@ -15,6 +15,18 @@ test.describe('Tests', () => { port: 5432, }); + test.before(async () => { + await client.connect(); + }); + + test.after(async () => { + await client.end(); + }); + + test.afterEach(async () => { + await client.query('DELETE FROM sessions'); + }); + test.it('Pizza counter test', async () => { const bot = utils.createBot(); @@ -36,14 +48,7 @@ test.describe('Tests', () => { await bot.handleUpdate(utils.createMessage(bot, 'second').update); }); - test.it('Should be changed', async () => { - const client = new pg.Client({ - user: 'postgres', - password: 'postgres', - database: 'postgres', - host: 'localhost', - port: 5432, - }); + test.it('Simple string', async () => { const bot = utils.createBot(false); bot.use(session({ @@ -62,8 +67,4 @@ test.describe('Tests', () => { await bot.handleUpdate(utils.createMessage(bot, 'first').update); await bot.handleUpdate(utils.createMessage(bot, 'second').update); }); - - test.after(async () => { - await client.end(); - }); });