I want to execute a test, using karma test runner over jasmine. for knowing if the app inserts correctly in a database using cordova-sqlite-storage plugin.
I create the karma.config.js file fine, but I don’t know how test a service that injects a cordova plugin.
my service.js is this:
var app = angular.module('starter');
app.service('baseDatosService', function ($cordovaSQLite, $rootScope, localStorageService, dispositivo) {
return {
insertarEnBD: function (tabla, objeto) {
var query = "INSERT INTO sesion (llaves) VALUES (?)";
console.log(query);
$cordovaSQLite.execute($rootScope.db, query, ["hola"]).then(function (result) {
console.log("correcto");
}, function (err) {
console.log("incorrecto" + err);
});
},
conectaBD: function () {
if (window.cordova && window.SQLitePlugin) {
$rootScope.db = window.sqlitePlugin.openDatabase({name: 'Pi.bd', location: 'default'});
} else {
$rootScope.db = window.openDatabase('Pi.bd', '1.0', 'Pi.db', 8 * 1024 * 1024);
}
},
};
});