Skip to content
Snippets Groups Projects
Commit 1b3bafd8 authored by William Andersson's avatar William Andersson
Browse files

tests and persondao

parent a807b66e
No related branches found
No related tags found
No related merge requests found
Pipeline #22828 passed
......@@ -20,6 +20,23 @@ module.exports = class PersonDao extends Dao {
val,
callback
);
//yo
}
updateOne(id, json, callback) {
let val = [json.navn, json.adresse, json.alder, id];
super.query(
"UPDATE person SET navn = ?, adresse = ?, alder = ? WHERE id = ?",
val,
callback
);
}
deleteOne(id, callback){
super.query(
"DELETE FROM person WHERE id = ?",
[id],
callback
);
}
};
......@@ -77,3 +77,26 @@ test("get all persons from db", done => {
personDao.getAll(callback);
});
test("update a person", done =>{
let id = 1;
function callback1(status, data) {
personDao.getOne(id, callback2)
}
function callback2(status, data) {
console.log(
"Test callback: status=" + status + ", data=" + JSON.stringify(data)
);
expect(data.length).toBe(1);
expect(data[0].alder).toBe(20);
expect(data[0].navn).toBe("Swaghetti");
done();
}
personDao.updateOne(
id,
{navn: "Swaghetti", adresse: "Toppen 25", alder: 20},
callback1
);
})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment