From 8c8249626dc3d50463d4ad89e75fb084faf46ba8 Mon Sep 17 00:00:00 2001 From: Ibrahim Mkusa Date: Mon, 19 Jun 2023 12:40:23 -0400 Subject: ex4.4 more unit tests and helper functions with jest --- part4/blog/utils/list_helper.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'part4/blog/utils') diff --git a/part4/blog/utils/list_helper.js b/part4/blog/utils/list_helper.js index e52c23c..871bbc3 100644 --- a/part4/blog/utils/list_helper.js +++ b/part4/blog/utils/list_helper.js @@ -1,5 +1,18 @@ +const logger = require('../utils/logger.js') const dummy = (blogs) => { return 1 } -module.exports = {dummy} + +const totalLikes = (blogs) => { + likes = 0 + for (const blog of blogs) { + likes += blog.likes + } + + return likes +} + +module.exports = { + dummy, totalLikes +} -- cgit v1.2.3