From a676ca5f8c82af01b25caec82a1332ed23566f67 Mon Sep 17 00:00:00 2001 From: oivindhl <oivindhl@stud.ntnu.no> Date: Tue, 25 Sep 2018 00:05:54 +0200 Subject: [PATCH] updateTest --- dao/persondao.js | 5 +---- dao/persondao.test.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/dao/persondao.js b/dao/persondao.js index 16aa480..8c392f1 100644 --- a/dao/persondao.js +++ b/dao/persondao.js @@ -23,12 +23,9 @@ module.exports = class PersonDao extends Dao { } updateOne(id, json, callback) { + var val = [json.navn, json.adresse, json.alder, id]; super.query( "update person set navn=?, adresse=?, alder=? where id=?", - [json.navn], - [json.adresse], - [json.alder], - [id], callback ) } diff --git a/dao/persondao.test.js b/dao/persondao.test.js index 79f786b..ce08284 100644 --- a/dao/persondao.test.js +++ b/dao/persondao.test.js @@ -75,5 +75,24 @@ test("get all persons from db", done => { done(); } + test("update person from db", done => { + function callback(status, data) { + personDao.getOne(2, getCallback); + } + + function getCallback(status, data) { + console.log( + "Test callback: status= " + status + ", data=" +JSON.stringify(data) + ); + expect(data.length).toBe(1); + expect(data[0].alder).toBe(23); + done(); + } + personDao.updateOne( + 2, + {navn: "Hei Heisen", adresse: "Gata 2", alder: "23"}, + callback + ); + }) personDao.getAll(callback); }); -- GitLab