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
Branches master
No related tags found
No related merge requests found
Pipeline #49677 canceled
......@@ -22,11 +22,10 @@ module.exports = class PersonDao extends Dao {
);
}
updateOne(id,nyNavn, callback) {
updateOne(json, callback) {
super.query(
"update person set navn=nynavn where id=?",
[id],
[nyNavn],
callback
);
}
......@@ -37,9 +36,4 @@ module.exports = class PersonDao extends Dao {
callback
);
}
countAll(callback){
super.query(
"SELECT COUNT(*) FROM person;",[],callback
)
}
};
......@@ -83,20 +83,20 @@ test("oppdater person to db", done => {
console.log(
"Test callback: status=" + status + ", data=" + JSON.stringify(data)
);
expect(data.affectedRows).toBe(1);
expect(data.affectedRows).toEqual(1);
done();
}
personDao.updateOne(
2,{navn: "Mahmoud"},callback);
personDao.updateOne({navn:"mahmoud",id:"2"}
,callback);
});
test("slett person to db", done => {
function callback(status) {
function callback(status, data) {
console.log(
"Test callback: status=" + status + ", data=" + JSON.stringify(data)
);
expect(personDao.countAll((status, data))).toEqual(1);
expect(data.affectedRows).toBeGreaterThanOrEqual(1);
done();
}
......
......@@ -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);
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