From 33438ffb956226088aefc3a3a15d88db624a4980 Mon Sep 17 00:00:00 2001 From: Oscar Franco Date: Sat, 14 Dec 2024 10:26:42 +0100 Subject: [PATCH] Add test for mutiple connections --- example/src/tests/queries.spec.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/example/src/tests/queries.spec.ts b/example/src/tests/queries.spec.ts index 6885927..fc41514 100644 --- a/example/src/tests/queries.spec.ts +++ b/example/src/tests/queries.spec.ts @@ -67,6 +67,30 @@ export function queriesTests() { // }); // } + it('Can create multiple connections to same db', async () => { + const db2 = open({ + name: 'queries.sqlite', + encryptionKey: 'test', + }); + + const db3 = open({ + name: 'queries.sqlite', + encryptionKey: 'test', + }); + + let promises = [ + db.execute('SELECT 1'), + db2.execute('SELECT 1'), + db3.execute('SELECT 1'), + ]; + + let res = await Promise.all(promises); + res.forEach(r => { + expect(r.rowsAffected).to.equal(0); + expect(r.rows[0]!['1']).to.equal(1); + }); + }); + it('Trying to pass object as param should throw', async () => { try { // @ts-ignore