From 11ead17bb4032b5ac1590de20a931839c1c2fc8c Mon Sep 17 00:00:00 2001 From: Siddhesh Bhupendra Kuakde <65951872+SiddheshKukade@users.noreply.github.com> Date: Wed, 8 Jun 2022 20:52:35 +0530 Subject: [PATCH] =?UTF-8?q?[Code=20Coverage]=20:=20=F0=9F=A4=96=20TEST:=20?= =?UTF-8?q?=20=20=20for=20=20lib/resolvers/group=5Fchat=5Fquery/groupChats?= =?UTF-8?q?.jsGroup=20=20(#710)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Test : lib/resolvers/group_chat_query/groupChatMessages.js * Add Test : Added Valid JSON Check * 🤖 TEST: for lib/resolvers/group_chat_query/groupChats.js * 🤖 TEST: for lib/resolvers/group_chat_query/groupChats.js * 🤖 TEST: Imrpoved Descriptions * removed the extra file --- .../group_chat_query/groupChats.spec.js | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/resolvers/group_chat_query/groupChats.spec.js diff --git a/tests/resolvers/group_chat_query/groupChats.spec.js b/tests/resolvers/group_chat_query/groupChats.spec.js new file mode 100644 index 0000000000..ce970e1827 --- /dev/null +++ b/tests/resolvers/group_chat_query/groupChats.spec.js @@ -0,0 +1,26 @@ +const database = require('../../../db'); +const groupChat = require('../../../lib/resolvers/group_chat_query/groupChats'); + +beforeAll(async () => { + require('dotenv').config(); // pull env variables from .env file + await database.connect(); +}); + +afterAll(async () => { + database.disconnect(); +}); + +describe('tests for lib/resolvers/group_chat_query/groupChats.js', () => { + test('Should return a JSON response (getting the group chat messages from the database)', async () => { + const res = await groupChat(); + expect(typeof res).toBe('object'); + }); + test('groupChat Produces metadata object that can be parsed to valid JSON', async () => { + const temp = await groupChat(); + const parseJson = () => { + const json = JSON.stringify(temp); + JSON.parse(json); + }; + expect(parseJson).not.toThrow(); + }); +});