From 52d1d8b757103d8db9c14b92473fa8faffdc3ad1 Mon Sep 17 00:00:00 2001 From: oivindhl <oivindhl@stud.ntnu.no> Date: Tue, 25 Sep 2018 00:41:32 +0200 Subject: [PATCH] first delete test --- dao/persondao.js | 8 ++++++++ dao/persondao.test.js | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/dao/persondao.js b/dao/persondao.js index 3bca0db..b437a6a 100644 --- a/dao/persondao.js +++ b/dao/persondao.js @@ -30,4 +30,12 @@ module.exports = class PersonDao extends Dao { callback ) } + + deleteOne(id, callback) { + super.query( + "delete from person where id = ?", + [id], + callback + ) + } }; diff --git a/dao/persondao.test.js b/dao/persondao.test.js index 805ab05..520a799 100644 --- a/dao/persondao.test.js +++ b/dao/persondao.test.js @@ -96,4 +96,16 @@ test("update person from db", done => { {navn: "Hei Heisen", adresse: "Gata 2", alder: "23"}, callback ); +}) + +test("delete person from db", done => { + function callback(staus, data) { + console.log( + "Test callback: status= " + status + ", data=" +JSON.stringify(data) + ); + expect(personDao.getAll(callback)).toBe(1); + expect(data.affectedRows).toBeGreaterThanOrEqual(1); + done(); + } + personDao.deleteOne(2, callback); }) \ No newline at end of file -- GitLab