From c92d3a6c5f1bb5cf62e6c99a8c134ed88de43600 Mon Sep 17 00:00:00 2001 From: "David Humphrey (:humph) david.humphrey@senecacollege.ca" Date: Wed, 27 Nov 2013 17:12:46 -0500 Subject: [PATCH] Passing 1/4 failing tests now --- src/providers/websql.js | 2 +- tests/spec/providers/providers.websql.spec.js | 42 +++++++------------ 2 files changed, 17 insertions(+), 27 deletions(-) diff --git a/src/providers/websql.js b/src/providers/websql.js index 7dc5f98..4b2e406 100644 --- a/src/providers/websql.js +++ b/src/providers/websql.js @@ -55,7 +55,7 @@ define(function(require) { callback(error); } this.getTransaction(function(transaction) { - transaction.executeSql("INSERT OR REPLACE INTO " + FILE_STORE_NAME + " (id, data)", + transaction.executeSql("INSERT OR REPLACE INTO " + FILE_STORE_NAME + " (id, data) VALUES (?, ?)", [key, value], onSuccess, onError); }); }; diff --git a/tests/spec/providers/providers.websql.spec.js b/tests/spec/providers/providers.websql.spec.js index ce5fbbc..82e8bb6 100644 --- a/tests/spec/providers/providers.websql.spec.js +++ b/tests/spec/providers/providers.websql.spec.js @@ -2,20 +2,18 @@ define(["IDBFS"], function(IDBFS) { var WEBSQL_NAME = "websql-test-db"; - function wipeDB() { - var provider = new IDBFS.FileSystem.providers.WebSQL(WEBSQL_NAME); - provider.open(function(err, firstAccess) { - if(err) { - console.error("Problem clearing WebSQL db: " + err); - return; - } - var context = provider.getReadWriteContext(); - context.clear(function(err) { - console.error("Problem clearing WebSQL db: " + err); - }); + function wipeDB(provider) { + var context = provider.getReadWriteContext(); + context.clear(function(err) { + console.error("Problem clearing WebSQL db: " + err); }); } + if(!IDBFS.FileSystem.providers.WebSQL.isSupported()) { + console.log("Skipping IDBFS.FileSystem.providers.WebSQL tests, since WebSQL isn't supported."); + return; + } + describe("IDBFS.FileSystem.providers.WebSQL", function() { it("is supported -- if it isn't, none of these tests can run.", function() { expect(IDBFS.FileSystem.providers.WebSQL.isSupported()).toEqual(true); @@ -29,19 +27,15 @@ define(["IDBFS"], function(IDBFS) { }); describe("open an WebSQL provider", function() { - beforeEach(function() { - wipeDB(); - }); - afterEach(function() { - wipeDB(); + wipeDB(this.provider); }); it("should open a new WebSQL database", function() { var complete = false; var _error, _result; - var provider = new IDBFS.FileSystem.providers.WebSQL(WEBSQL_NAME); + var provider = this.provider = this.provider = new IDBFS.FileSystem.providers.WebSQL(WEBSQL_NAME); provider.open(function(err, firstAccess) { _error = err; _result = firstAccess; @@ -60,19 +54,15 @@ define(["IDBFS"], function(IDBFS) { }); describe("Read/Write operations on an WebSQL provider", function() { - beforeEach(function() { - wipeDB(); - }); - afterEach(function() { - wipeDB(); + wipeDB(this.provider); }); it("should allow put() and get()", function() { var complete = false; var _error, _result; - var provider = new IDBFS.FileSystem.providers.WebSQL(WEBSQL_NAME); + var provider = this.provider = new IDBFS.FileSystem.providers.WebSQL(WEBSQL_NAME); provider.open(function(err, firstAccess) { _error = err; @@ -102,7 +92,7 @@ define(["IDBFS"], function(IDBFS) { var complete = false; var _error, _result; - var provider = new IDBFS.FileSystem.providers.WebSQL(WEBSQL_NAME); + var provider = this.provider = new IDBFS.FileSystem.providers.WebSQL(WEBSQL_NAME); provider.open(function(err, firstAccess) { _error = err; @@ -135,7 +125,7 @@ define(["IDBFS"], function(IDBFS) { var complete = false; var _error, _result1, _result2; - var provider = new IDBFS.FileSystem.providers.WebSQL(WEBSQL_NAME); + var provider = this.provider = new IDBFS.FileSystem.providers.WebSQL(WEBSQL_NAME); provider.open(function(err, firstAccess) { _error = err; @@ -179,7 +169,7 @@ define(["IDBFS"], function(IDBFS) { var complete = false; var _error, _result; - var provider = new IDBFS.FileSystem.providers.WebSQL(WEBSQL_NAME); + var provider = this.provider = new IDBFS.FileSystem.providers.WebSQL(WEBSQL_NAME); provider.open(function(err, firstAccess) { _error = err;