I am new to Qunit.
I want to test PhoneGap application containig SQLite database coding by Qunit.Can anyone give me suggestion,How I can do that?
window.addEventListener('load', function(){
// Wait for PhoneGap to load
document.addEventListener("deviceready", onDeviceReady, false);
}, false);
// PhoneGap is ready
function onDeviceReady() {
var db = window.openDatabase("Database2", "1.0", "DigitalNoiz", 200000);
var submitBtn = $("#submit");
submitBtn.click(function(){
db.transaction(populateDB, errorCB, successCB);
});
}
// Populate the database
function populateDB(u) {
var setStartDate =$("#StartDate");
var setAllergyType=$("#AllergyType");
var setSeverity =$("#Severity");
var setReaction =$("#Reaction");
var setNotes =$("#Notes");
u.executeSql('DROP TABLE IF EXISTS Allergy');
u.executeSql('CREATE TABLE IF NOT EXISTS Allergy (StartDate varchar(20), AllergyType varchar(20), Severity varchar(20), Reaction varchar(20),Notes text)');
u.executeSql('INSERT INTO Allergy (StartDate,AllergyType,Severity,Reaction,Notes) VALUES ("' + setStartDate.val() + '", "' + setAllergyType.val() + '", "' + setSeverity.val() + '", "' + setReaction.val() + '","' + setNotes.val() + '")');
QUnit.test( "a basic test example", function( assert ) {
assert.ok( true, setNotes );
});
}
// Query the database
// Transaction error callback
function errorCB(err) {
console.log("Error processing SQL: "+err.code);
}
// Transaction success callback
function successCB() {
alert('Allergy details submitted successfully');
var db = window.openDatabase("Database", "1.0", "DigitalNoiz", 200000);
window.open("Allergy.html",'_self');
location.reload(false);
}