Skip to content
This repository was archived by the owner on Jul 7, 2022. It is now read-only.

Commit 47102b9

Browse files
committed
Convert a callback test into a promise test to fully test execSQL
1 parent dc75fc0 commit 47102b9

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

demo/app/main-page.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,16 @@ function setupTests(callback) {
118118
console.log("!---- Insert err", err);
119119
return;
120120
}
121-
db.execSQL('insert into tests (int_field, num_field, real_field, text_field) values (2,4.8,5.6,"Text2")', callback);
121+
db.execSQL('insert into tests (int_field, num_field, real_field, text_field) values (2,4.8,5.6,"Text2")').then(() => {
122+
callback();
123+
}).catch((err) => {
124+
if (err) {
125+
data.push({name: 'Failed to insert data into tests', css: 'one'});
126+
console.log("!---- Insert err2:", err);
127+
return;
128+
}
129+
callback(err);
130+
});
122131
});
123132
});
124133
});
@@ -249,6 +258,14 @@ function runATest(options, callback) {
249258
db.each(options.sql, options.values, checkEachResults).then(checkFinalResults).catch(promiseFailed);
250259
break;
251260

261+
case 6:
262+
db.execSQL(options.sql, options.params, checkResults);
263+
break;
264+
265+
case 7:
266+
db.execSQL(options.sql, options.params).then(promiseResults).catch(promiseFailed);
267+
break;
268+
252269
default:
253270
callback(false);
254271
}
@@ -268,12 +285,20 @@ function runATest(options, callback) {
268285
db.get(options.sql).then(promiseResults).catch(promiseFailed);
269286
break;
270287
case 4:
271-
let p = db.all(options.sql).then(promiseResults).catch(promiseFailed);
288+
db.all(options.sql).then(promiseResults).catch(promiseFailed);
272289
break;
273290
case 5:
274291
db.each(options.sql, checkEachResults).then(checkFinalResults).catch(promiseFailed);
275292
break;
276293

294+
case 6:
295+
db.execSQL(options.sql, checkResults);
296+
break;
297+
298+
case 7:
299+
db.execSQL(options.sql).then(promiseResults).catch(promiseFailed);
300+
break;
301+
277302

278303
default:
279304
callback(false);

src/changelog

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ v2.2.4 - Fix CopyDatabase on Android to respect the app version (for livesync)
2626
v2.2.5 - Fix CopyDatabase indexOf to lastIndexOf - Thanks Webleaf
2727
v2.2.6 - Forgot to include the ios sqlite helper in v2.2.4/v2.2.5
2828
v2.3.0 - Several minor issues fixed, Multi-threading added to Sqlite
29-
v2.3.1 - iOS SQLExec bind returns the wrong error value
29+
v2.3.1 - iOS SQLExec bind returns the wrong error value
30+
v2.3.2 - Added Promise tests, started ES6 updated.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy