From db2105022c9dd70b6a8a0592afb30a4bf05cf158 Mon Sep 17 00:00:00 2001 From: Oscar Franco Date: Sun, 22 Dec 2024 09:40:40 +0100 Subject: [PATCH] Fix tests --- .github/workflows/ci.yml | 5 ----- example/src/tests/hooks.spec.ts | 30 +++++++++++++----------------- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 82200a56..a02ebef4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -264,17 +264,12 @@ jobs: ${{ runner.os }}-cocoapods- - name: Install cocoapods - # if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true' run: | cd example/ios bundle exec pod install env: NO_FLIPPER: 1 - # - name: Build example for iOS - # run: | - # yarn turbo run run:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" - - name: run tests run: | ./scripts/test-ios.sh diff --git a/example/src/tests/hooks.spec.ts b/example/src/tests/hooks.spec.ts index c85de340..1a9105b2 100644 --- a/example/src/tests/hooks.spec.ts +++ b/example/src/tests/hooks.spec.ts @@ -51,7 +51,6 @@ export function registerHooksTests() { }); db.updateHook(data => { - console.log('UPDATE HOOK CALLED'); promiseResolve(data); }); @@ -66,8 +65,6 @@ export function registerHooksTests() { ); }); - console.log('AWAITING UPDATE HOOK PROMISE'); - const data = await promise; expect(data.operation).to.equal('INSERT'); @@ -78,10 +75,7 @@ export function registerHooksTests() { it('remove update hook', async () => { const hookRes: string[] = []; - let db = open({ - name: 'updateHookDb.sqlite', - encryptionKey: 'blah', - }); + db.updateHook(({operation}) => { hookRes.push(operation); }); @@ -90,19 +84,21 @@ export function registerHooksTests() { const name = chance.name(); const age = chance.integer(); const networth = chance.floating(); - // await db.transaction(async tx => { - await db.execute( - 'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)', - [id, name, age, networth], - ); - // }); + await db.transaction(async tx => { + await tx.execute( + 'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)', + [id, name, age, networth], + ); + }); db.updateHook(null); - await db.execute( - 'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)', - [id + 1, name, age, networth], - ); + await db.transaction(async tx => { + await tx.execute( + 'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)', + [id + 1, name, age, networth], + ); + }); await sleep(0);