Add nested transaction test

This commit is contained in:
Chris Brody 2012-12-05 19:52:52 +01:00
parent 76bbceca8c
commit 5657b83420

View File

@ -18,7 +18,7 @@
function doTest() {
test( "db transaction test", function() {
test("db transaction test", function() {
var db = window.sqlitePlugin.openDatabase("Database", "1.0", "PhoneGap Demo", 200000);
@ -42,7 +42,7 @@
console.log("insertId: " + res.insertId + " -- probably 1");
console.log("rowsAffected: " + res.rowsAffected + " -- should be 1");
ok(!!res.insertId, "Valid res.insertId"); /* issue #18 (Android) */
ok(!!res.insertId, "Valid res.insertId");
// equal(res.rowsAffected, 1, "res rows affected"); // issue with Android version
db.transaction(function(tx) {
@ -104,6 +104,48 @@
});
test("nested transaction test", function() {
var db = window.sqlitePlugin.openDatabase("Database", "1.0", "PhoneGap Demo", 200000);
ok(!!db, "db object");
stop(3);
db.transaction(function(tx) {
start(1);
ok(!!tx, "tx object");
tx.executeSql('DROP TABLE IF EXISTS test_table');
tx.executeSql('CREATE TABLE IF NOT EXISTS test_table (id integer primary key, data text, data_num integer)');
tx.executeSql("INSERT INTO test_table (data, data_num) VALUES (?,?)", ["test", 100], function(tx, res) {
start(1);
console.log("insertId: " + res.insertId + " -- probably 1");
console.log("rowsAffected: " + res.rowsAffected + " -- should be 1");
ok(!!res.insertId, "Valid res.insertId");
// equal(res.rowsAffected, 1, "res rows affected"); // issue with Android version
tx.executeSql("select count(id) as cnt from test_table;", [], function(tx, res) {
start(1);
console.log("res.rows.length: " + res.rows.length + " -- should be 1");
console.log("res.rows.item(0).cnt: " + res.rows.item(0).cnt + " -- should be 1");
equal(res.rows.length, 1, "res rows length");
equal(res.rows.item(0).cnt, 1, "select count");
});
});
});
});
}
</script>