@@ -3,9 +3,10 @@ import type {
3
3
QuickSQLiteConnection ,
4
4
BatchQueryCommand ,
5
5
} from 'react-native-quick-sqlite'
6
- import { beforeEach , describe , it } from './MochaRNAdapter'
6
+ import { beforeEach , describe , it } from './MochaRNAdapter'
7
7
import chai from 'chai'
8
- import { testDb as testDbInternal , resetTestDb } from './db'
8
+ import { testDb as testDbInternal , resetTestDb } from './db'
9
+ import { User } from '../model/User'
9
10
10
11
function isError ( e : unknown ) : e is Error {
11
12
return e instanceof Error
@@ -129,7 +130,7 @@ export function registerUnitTests() {
129
130
const age = chance . integer ( )
130
131
const networth = chance . floating ( )
131
132
132
- await testDb . transaction ( tx => {
133
+ await testDb . transaction ( ( tx ) => {
133
134
const res = tx . execute (
134
135
'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)' ,
135
136
[ id , name , age , networth ]
@@ -159,7 +160,7 @@ export function registerUnitTests() {
159
160
const age = chance . integer ( )
160
161
const networth = chance . floating ( )
161
162
162
- await testDb . transaction ( tx => {
163
+ await testDb . transaction ( ( tx ) => {
163
164
const res = tx . execute (
164
165
'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)' ,
165
166
[ id , name , age , networth ]
@@ -198,7 +199,7 @@ export function registerUnitTests() {
198
199
// ACT: Start multiple transactions to upsert and select the same record
199
200
const promises = [ ]
200
201
for ( let iteration = 1 ; iteration <= iterations ; iteration ++ ) {
201
- const promised = testDb . transaction ( tx => {
202
+ const promised = testDb . transaction ( ( tx ) => {
202
203
// ACT: Upsert statement to create record / increment the value
203
204
tx . execute (
204
205
`
@@ -245,7 +246,7 @@ export function registerUnitTests() {
245
246
const age = chance . integer ( )
246
247
const networth = chance . floating ( )
247
248
248
- await testDb . transaction ( tx => {
249
+ await testDb . transaction ( ( tx ) => {
249
250
const res = tx . execute (
250
251
'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)' ,
251
252
[ id , name , age , networth ]
@@ -283,7 +284,7 @@ export function registerUnitTests() {
283
284
const age = chance . integer ( )
284
285
const networth = chance . floating ( )
285
286
286
- await testDb . transaction ( tx => {
287
+ await testDb . transaction ( ( tx ) => {
287
288
try {
288
289
tx . execute (
289
290
'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)' ,
@@ -319,7 +320,7 @@ export function registerUnitTests() {
319
320
const age = chance . integer ( )
320
321
const networth = chance . floating ( )
321
322
322
- await testDb . transaction ( tx => {
323
+ await testDb . transaction ( ( tx ) => {
323
324
tx . execute (
324
325
'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)' ,
325
326
[ id , name , age , networth ]
@@ -347,7 +348,7 @@ export function registerUnitTests() {
347
348
} )
348
349
349
350
it ( 'Transaction, rejects on invalid query' , async ( ) => {
350
- const promised = testDb . transaction ( tx => {
351
+ const promised = testDb . transaction ( ( tx ) => {
351
352
tx . execute ( 'SELECT * FROM [tableThatDoesNotExist];' )
352
353
} )
353
354
// ASSERT: should return a promise that eventually rejects
@@ -364,8 +365,8 @@ export function registerUnitTests() {
364
365
365
366
it ( 'Transaction, handle async callback' , async ( ) => {
366
367
let ranCallback = false
367
- const promised = testDb . transaction ( async tx => {
368
- await new Promise < void > ( done => {
368
+ const promised = testDb . transaction ( async ( tx ) => {
369
+ await new Promise < void > ( ( done ) => {
369
370
setTimeout ( ( ) => done ( ) , 50 )
370
371
} )
371
372
tx . execute ( 'SELECT * FROM [User];' )
@@ -384,7 +385,7 @@ export function registerUnitTests() {
384
385
const age = chance . integer ( )
385
386
const networth = chance . floating ( )
386
387
387
- await testDb . transaction ( async tx => {
388
+ await testDb . transaction ( async ( tx ) => {
388
389
const res = await tx . executeAsync (
389
390
'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)' ,
390
391
[ id , name , age , networth ]
@@ -415,7 +416,7 @@ export function registerUnitTests() {
415
416
const networth = chance . floating ( )
416
417
417
418
try {
418
- await testDb . transaction ( async tx => {
419
+ await testDb . transaction ( async ( tx ) => {
419
420
await tx . executeAsync (
420
421
'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)' ,
421
422
[ id , name , age , networth ]
@@ -441,7 +442,7 @@ export function registerUnitTests() {
441
442
const age = chance . integer ( )
442
443
const networth = chance . floating ( )
443
444
444
- await testDb . transaction ( async tx => {
445
+ await testDb . transaction ( async ( tx ) => {
445
446
await tx . executeAsync (
446
447
'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)' ,
447
448
[ id , name , age , networth ]
@@ -466,7 +467,7 @@ export function registerUnitTests() {
466
467
const age = chance . integer ( )
467
468
const networth = chance . floating ( )
468
469
469
- await testDb . transaction ( async tx => {
470
+ await testDb . transaction ( async ( tx ) => {
470
471
await tx . executeAsync (
471
472
'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)' ,
472
473
[ id , name , age , networth ]
@@ -491,7 +492,7 @@ export function registerUnitTests() {
491
492
// ACT: Start multiple async transactions to upsert and select the same record
492
493
const promises = [ ]
493
494
for ( let iteration = 1 ; iteration <= iterations ; iteration ++ ) {
494
- const promised = testDb . transaction ( async tx => {
495
+ const promised = testDb . transaction ( async ( tx ) => {
495
496
// ACT: Upsert statement to create record / increment the value
496
497
await tx . executeAsync (
497
498
`
@@ -549,7 +550,7 @@ export function registerUnitTests() {
549
550
} )
550
551
551
552
it ( 'Async transaction, rejects on invalid query' , async ( ) => {
552
- const promised = testDb . transaction ( async tx => {
553
+ const promised = testDb . transaction ( async ( tx ) => {
553
554
await tx . executeAsync ( 'SELECT * FROM [tableThatDoesNotExist];' )
554
555
} )
555
556
@@ -592,7 +593,7 @@ export function registerUnitTests() {
592
593
593
594
const res = testDb . execute ( 'SELECT * FROM User' )
594
595
expect ( res . rows ?. _array ) . to . eql ( [
595
- { id : id1 , name : name1 , age : age1 , networth : networth1 } ,
596
+ { id : id1 , name : name1 , age : age1 , networth : networth1 } ,
596
597
{
597
598
id : id2 ,
598
599
name : name2 ,
@@ -628,7 +629,7 @@ export function registerUnitTests() {
628
629
629
630
const res = testDb . execute ( 'SELECT * FROM User' )
630
631
expect ( res . rows ?. _array ) . to . eql ( [
631
- { id : id1 , name : name1 , age : age1 , networth : networth1 } ,
632
+ { id : id1 , name : name1 , age : age1 , networth : networth1 } ,
632
633
{
633
634
id : id2 ,
634
635
name : name2 ,
0 commit comments