From a2ebf542ed562eebf2e4f80fb66fe954c32b071e Mon Sep 17 00:00:00 2001 From: Sven Eppler Date: Mon, 17 Jan 2022 10:05:27 +0100 Subject: [PATCH 1/5] Really fix endpoint! --- src/api/routes/api/contacts.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/api/routes/api/contacts.js b/src/api/routes/api/contacts.js index f8015fd..0fd40c7 100644 --- a/src/api/routes/api/contacts.js +++ b/src/api/routes/api/contacts.js @@ -10,6 +10,7 @@ const addressbook = new Addressbook(); router.get("/contacts", (req, res) => { const contactsList = addressbook.getContacts(); + res.status(400); res.send(contactsList); }); From bcd0e2fee1fc43958d509aa0e998fd765206102f Mon Sep 17 00:00:00 2001 From: Sven Eppler Date: Mon, 17 Jan 2022 10:12:16 +0100 Subject: [PATCH 2/5] respond with 200 ok --- src/api/routes/api/contacts.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/api/routes/api/contacts.js b/src/api/routes/api/contacts.js index 0fd40c7..f8015fd 100644 --- a/src/api/routes/api/contacts.js +++ b/src/api/routes/api/contacts.js @@ -10,7 +10,6 @@ const addressbook = new Addressbook(); router.get("/contacts", (req, res) => { const contactsList = addressbook.getContacts(); - res.status(400); res.send(contactsList); }); From f5ca91a3931653ed52800a492fd894d688f64a20 Mon Sep 17 00:00:00 2001 From: Sven Eppler Date: Mon, 17 Jan 2022 10:17:53 +0100 Subject: [PATCH 3/5] add unit test for fullName method --- test/contact.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/contact.js b/test/contact.js index 7746b74..e1e7847 100644 --- a/test/contact.js +++ b/test/contact.js @@ -25,5 +25,12 @@ describe("Contact Class", () => { it("throws on undefined firstname", () => assert.throws(() => new Contact(nanoid(), undefined, "LastName"))); it("throws on undefined lastname", () => assert.throws(() => new Contact(nanoid(), "FirstName", undefined))); + it("should return the full name", () => { + var newContact = new Contact(123, "My FirstName", "My LastName", "Nickname", "1990-01-01"); + + const fullName = newContact.fullName(); + + fullName.should.be.equal("My LastName, My FirstName"); + }) }); }); \ No newline at end of file From cdb1f8d0e4a2abbbbe26d2f112c6055619484867 Mon Sep 17 00:00:00 2001 From: Sven Eppler Date: Mon, 17 Jan 2022 10:25:08 +0100 Subject: [PATCH 4/5] add important parameter --- src/lib/contact.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/contact.js b/src/lib/contact.js index 7202aae..2b88e84 100644 --- a/src/lib/contact.js +++ b/src/lib/contact.js @@ -22,7 +22,7 @@ class Contact { assertIsNotUndefinedNullOrEmpty(this.lastname, "lastName"); } - fullName() { + fullName(useLessParam) { return this.lastname + ", " + this.firstname; } } From 455c0a279faa6cc73b51d19286fc9b8d6a0bc0d9 Mon Sep 17 00:00:00 2001 From: Sven Eppler Date: Mon, 17 Jan 2022 10:26:56 +0100 Subject: [PATCH 5/5] Revert "add important parameter" This reverts commit cdb1f8d0e4a2abbbbe26d2f112c6055619484867. --- src/lib/contact.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/contact.js b/src/lib/contact.js index 2b88e84..7202aae 100644 --- a/src/lib/contact.js +++ b/src/lib/contact.js @@ -22,7 +22,7 @@ class Contact { assertIsNotUndefinedNullOrEmpty(this.lastname, "lastName"); } - fullName(useLessParam) { + fullName() { return this.lastname + ", " + this.firstname; } }