Unit tests with QUnit

1

Good afternoon,

I am working on a project with Intel XDK and I use javascript functions in html files. I need to perform unit tests to verify that the functions work correctly. I am using Qunit for it and I get an error in the test when looking for a user in the database. Create a test file and in the html file I entered the script headers of QUnit but I do not understand why it gives me an error when searching for a patient. I use the code of both.

   ***test.js***
QUnit.test("Mi Primera Prueba",function (assert) {
    assert.ok(buscarpacient("121"),"Satisfactorio");
});

QUnit.test( "hello test", function( ) {
  ok( 1 == "1", "Passed!" );
});

***buscarpacient.html***

function buscarpacient() {

        var active = dataBase.result;
        var data = active.transaction(["pacientes"],"readwrite");
        var object = data.objectStore("pacientes");    

        // primero buscamos el registro a partir del dni
        var index = object.index("by_dni");
        var request = index.get(calcMD5(document.querySelector("#dni1").value));//calcMD5(document.querySelector("#dni1").value)

         request.onerror = function(event) {
         alert("Why didn't you allow my web app to use IndexedDB?!");
         };
        // cuando se encuentre el registro, lo borramos
        request.onsuccess = function () {
        if(request.result == undefined)
        {
         alert('No existe ese paciente');   
        }else{
        var result = request.result;
        alert("There the patient and has the ID: " + result.id);
        passdata(document.querySelector("#dni1").value);
        //anterior antes de md5 passdata(result.dni);

        //object.delete(result.id);
          }
        };
    } 

Greetings and thanks.

    
asked by Aaron VC 06.07.2016 в 17:45
source

0 answers