Skip to content
Snippets Groups Projects
Commit b22719f8 authored by Mahmoud Ibrahim Mohammad's avatar Mahmoud Ibrahim Mohammad
Browse files

Testing update and delete person

parent ebabd76b
No related branches found
No related tags found
No related merge requests found
Pipeline #49677 canceled
...@@ -22,11 +22,10 @@ module.exports = class PersonDao extends Dao { ...@@ -22,11 +22,10 @@ module.exports = class PersonDao extends Dao {
); );
} }
updateOne(id,nyNavn, callback) { updateOne(json, callback) {
super.query( super.query(
"update person set navn=nynavn where id=?", "update person set navn=nynavn where id=?",
[id], [id],
[nyNavn],
callback callback
); );
} }
...@@ -37,9 +36,4 @@ module.exports = class PersonDao extends Dao { ...@@ -37,9 +36,4 @@ module.exports = class PersonDao extends Dao {
callback callback
); );
} }
countAll(callback){
super.query(
"SELECT COUNT(*) FROM person;",[],callback
)
}
}; };
...@@ -83,20 +83,20 @@ test("oppdater person to db", done => { ...@@ -83,20 +83,20 @@ test("oppdater person to db", done => {
console.log( console.log(
"Test callback: status=" + status + ", data=" + JSON.stringify(data) "Test callback: status=" + status + ", data=" + JSON.stringify(data)
); );
expect(data.affectedRows).toBe(1); expect(data.affectedRows).toEqual(1);
done(); done();
} }
personDao.updateOne( personDao.updateOne({navn:"mahmoud",id:"2"}
2,{navn: "Mahmoud"},callback); ,callback);
}); });
test("slett person to db", done => { test("slett person to db", done => {
function callback(status) { function callback(status, data) {
console.log( console.log(
"Test callback: status=" + status + ", data=" + JSON.stringify(data) "Test callback: status=" + status + ", data=" + JSON.stringify(data)
); );
expect(personDao.countAll((status, data))).toEqual(1); expect(data.affectedRows).toBeGreaterThanOrEqual(1);
done(); done();
} }
......
...@@ -57,12 +57,6 @@ app.delete("/person/:personId", (req, res) => { ...@@ -57,12 +57,6 @@ app.delete("/person/:personId", (req, res) => {
}); });
}); });
app.get("/person", (req, res) => {
console.log("/person: fikk request fra klient");
personDao.countAll((status, data) => {
res.status(status);
res.json(data);
});
});
var server = app.listen(8080); var server = app.listen(8080);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment