From f1b19a7bfa9307020acd92c6c70b427ac0e62e48 Mon Sep 17 00:00:00 2001 From: Nongnooch Roongpiboonsopit Date: Thu, 12 Aug 2021 22:14:06 +0700 Subject: [PATCH] Add tests + Update src to enhance testability --- __tests__/e2e/prodApp.test.js | 101 + __tests__/server/Utils.test.js | 41 + .../design_artifacts/app_architecture.md | 22 + .../seq_diagram_faqworkflow.svg | 1 + client/package.json | 6 +- client/src/App.js | 4 +- client/src/App.test.js | 8 - client/src/__tests__/App.test.js | 117 + .../src/__tests__/components/HCPInfo.test.js | 50 + .../src/__tests__/components/Landing.test.js | 26 + .../src/__tests__/components/Response.test.js | 60 + .../__snapshots__/Landing.test.js.snap | 318 ++ .../__tests__/services/HCLSDKService.test.js | 83 + .../src/__tests__/services/QnAService.test.js | 97 + client/src/components/Layout/Layout.js | 7 +- client/src/components/QnA/HCPInfo.js | 29 +- client/src/components/QnA/QnA.js | 8 +- client/src/services/QnAService.js | 4 +- client/src/setupTests.js | 3 + client/yarn.lock | 3769 +++++++++-------- jest-playwright.config.js | 42 + jest.e2e.config.js | 5 + package.json | 12 +- yarn.lock | 1342 ------ 24 files changed, 2967 insertions(+), 3188 deletions(-) create mode 100644 __tests__/e2e/prodApp.test.js create mode 100644 __tests__/server/Utils.test.js create mode 100644 artifacts/design_artifacts/app_architecture.md create mode 100644 artifacts/design_artifacts/seq_diagram_faqworkflow.svg delete mode 100644 client/src/App.test.js create mode 100644 client/src/__tests__/App.test.js create mode 100644 client/src/__tests__/components/HCPInfo.test.js create mode 100644 client/src/__tests__/components/Landing.test.js create mode 100644 client/src/__tests__/components/Response.test.js create mode 100644 client/src/__tests__/components/__snapshots__/Landing.test.js.snap create mode 100644 client/src/__tests__/services/HCLSDKService.test.js create mode 100644 client/src/__tests__/services/QnAService.test.js create mode 100644 jest-playwright.config.js create mode 100644 jest.e2e.config.js delete mode 100644 yarn.lock diff --git a/__tests__/e2e/prodApp.test.js b/__tests__/e2e/prodApp.test.js new file mode 100644 index 0000000..9392937 --- /dev/null +++ b/__tests__/e2e/prodApp.test.js @@ -0,0 +1,101 @@ +// server needs to start before running this test +// % node index.js + +// Needs to be higher than the default Playwright timeout +jest.setTimeout(40 * 1000) + +const { chromium, firefox, webkit, devices } = require("playwright"); + +const deviceList = [ + 'Galaxy S8', + // 'iPad Pro 11', + 'iPad Mini landscape', + // 'iPhone 8', + 'iPhone 12', + 'Pixel 2 XL', + // 'Pixel 5 landscape', + 'Desktop Safari', + 'Desktop Chrome', + 'Dekstop Edge', + 'Desktop Firefox', +]; + +describe.each([ + [chromium.name(), chromium], + [firefox.name(), firefox], + [webkit.name(), webkit], +])('test on %p', (_browserName, browserType) => { + + let newBrowser; + + beforeAll(async () => { + newBrowser = await browserType.launch(); + // // For debugging + // newBrowser = await browserType.launch({ + // // slowMo: 250, + // headless: false + // }); + }); + + afterAll(async () => { + await newBrowser.close(); + }); + + it.each(deviceList)('(#%s) should render the built app', async (curDeviceName) => { + + let context + try { + context = await newBrowser.newContext({ + ...devices[curDeviceName], + + // Required when clicking Submit + geolocation: { longitude: 48.858455, latitude: 2.294474 }, + permissions: ['geolocation'] + }); + } catch (e) { + console.log(`Skip test in "${_browserName}" `); + return + } + + const page = await context.newPage(); + await page.goto('http://localhost:8080'); + + await expect(page).toHaveSelector('[data-testid="nav-item-brand"]'); + + const selector = '[data-testid="nav-item-askbuddy"]'; + await page.click(selector); + await expect(page).toHaveSelector('[data-testid="qna-container"]'); + + + const selectorResContainer = '[data-testid="response-container"]'; + const elResContainerBefore = await page.$(selectorResContainer); + const elResContainerContentBefore = await elResContainerBefore.textContent(); + expect(elResContainerContentBefore).toBeFalsy(); + + // await page.pause() + + // Click [placeholder="Select or type question or category..."] + await page.click('[placeholder="Select or type question or category..."]'); + + // Click text=What can we do so that other diseases like COVID-19 do not affect us in future?C + // await page.click('text=What can we do so that other diseases like COVID-19 do not affect us in future?C'); + await page.click('#faq-typeahead-item-0'); + const element = await page.$('input[placeholder="Select or type question or category..."]'); + + const elemValue = await element.inputValue(); + expect(elemValue).toBeTruthy(); + + // Click text=Submit + await page.click('text=Submit'); + + // Poll until the response shows up + await page.waitForSelector('[data-testid="response-item"]'); + + const elResContainerAfter = await page.$(selectorResContainer); + const elResContainerContentAfter = await elResContainerAfter.textContent(); + expect(elResContainerContentAfter).toBeTruthy(); + + await page.close(); + }); + +}); diff --git a/__tests__/server/Utils.test.js b/__tests__/server/Utils.test.js new file mode 100644 index 0000000..f5c64e5 --- /dev/null +++ b/__tests__/server/Utils.test.js @@ -0,0 +1,41 @@ +const { zipWith } = require('../../server/Utils'); + +describe('tUtils', () => { + + it('zipWith should return an appropriate output', () => { + + const myFcn = (a, b) => [a, b]; + + // --- When xs and ys has the same number of elements + let xs = [1, 2, 3]; + let ys = [4, 5, 6]; + + const actSameElems = zipWith(myFcn, xs, ys); + expect(actSameElems).toEqual([ + [1, 4], + [2, 5], + [3, 6] + ]); + + // --- When a number of Elements in xs of LESS than a number of element of ys + xs = [1, 2]; + ys = [4, 5, 6]; + + const actXsLessThanYs = zipWith(myFcn, xs, ys); + expect(actXsLessThanYs).toEqual([ + [1, 4], + [2, 5] + ]); + + // --- When a number of Elements in xs of GREATER than a number of element of ys + xs = [1, 2, 3]; + ys = [4]; + + const actXsGtYs = zipWith(myFcn, xs, ys); + expect(actXsGtYs).toEqual([ + [1, 4] + ]); + + }); + +}); \ No newline at end of file diff --git a/artifacts/design_artifacts/app_architecture.md b/artifacts/design_artifacts/app_architecture.md new file mode 100644 index 0000000..e766e3e --- /dev/null +++ b/artifacts/design_artifacts/app_architecture.md @@ -0,0 +1,22 @@ + +## Sequence diagram + +### FAQ Workflow +![FAQ Workflow](./seq_diagram_faqworkflow.svg) + +The sequence diagram above was created from https://sequencediagram.org/ using the syntaxes below: + +``` +title FAQ Workflow + +User->Client-FAQ:Select a FAQ +Client-FAQ->Client-QnAService:getFAQResponseById(id) +Client-QnAService->Server: axios.get(`/getfaqresponse?id=${id}`) +Server->Server-QnAService: getFAQResponseById(id) +Server-QnAService->Server: [Object] faqresponse +Server->Client-QnAService: {data: faqresponse} + +Client-QnAService->Client-FAQ: faqresponse +Client-FAQ->Client-FAQ: Render FAQ result + +``` \ No newline at end of file diff --git a/artifacts/design_artifacts/seq_diagram_faqworkflow.svg b/artifacts/design_artifacts/seq_diagram_faqworkflow.svg new file mode 100644 index 0000000..0e77892 --- /dev/null +++ b/artifacts/design_artifacts/seq_diagram_faqworkflow.svg @@ -0,0 +1 @@ +title%20FAQ%20Workflow%0A%0AUser-%3EClient-FAQ%3ASelect%20a%20FAQ%0AClient-FAQ-%3EClient-QnAService%3AgetFAQResponseById(id)%0AClient-QnAService-%3EServer%3A%20axios.get(%60%2Fgetfaqresponse%3Fid%3D%24%7Bid%7D%60)%0AServer-%3EServer-QnAService%3A%20getFAQResponseById(id)%0AServer-QnAService-%3EServer%3A%20%5BObject%5D%20faqresponse%0AServer-%3EClient-QnAService%3A%20%7Bdata%3A%20faqresponse%7D%0A%0AClient-QnAService-%3EClient-FAQ%3A%20faqresponse%0AClient-FAQ-%3EClient-FAQ%3A%20Render%20FAQ%20resultFAQ WorkflowUserClient-FAQClient-QnAServiceServerServer-QnAServiceSelect a FAQgetFAQResponseById(id)axios.get(`/getfaqresponse?id=${id}`)getFAQResponseById(id)[Object] faqresponse{data: faqresponse}faqresponseRender FAQ result \ No newline at end of file diff --git a/client/package.json b/client/package.json index 493d3fb..31bd344 100644 --- a/client/package.json +++ b/client/package.json @@ -22,7 +22,7 @@ "scripts": { "start": "react-scripts start", "build": "react-scripts build", - "test": "react-scripts test", + "test": "react-scripts test --transformIgnorePatterns 'node_modules/(?!@codemirror)/'", "eject": "react-scripts eject" }, "eslintConfig": { @@ -42,5 +42,9 @@ "last 1 firefox version", "last 1 safari version" ] + }, + "devDependencies": { + "puppeteer": "^10.2.0", + "react-test-renderer": "^17.0.2" } } diff --git a/client/src/App.js b/client/src/App.js index 1c2cdda..7bac399 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -1,7 +1,7 @@ import React, { useState, useEffect } from 'react'; import { Link, Redirect, Route, Switch, useHistory, useLocation } from 'react-router-dom'; import { Modal } from 'react-bootstrap'; -import GitHubButton from 'react-github-btn' +import GitHubButton from 'react-github-btn'; // Components import Layout from './components/Layout/Layout'; @@ -244,7 +244,7 @@ function App() {
-
+
{ - render(); - const linkElement = screen.getByText(/learn react/i); - expect(linkElement).toBeInTheDocument(); -}); diff --git a/client/src/__tests__/App.test.js b/client/src/__tests__/App.test.js new file mode 100644 index 0000000..224413b --- /dev/null +++ b/client/src/__tests__/App.test.js @@ -0,0 +1,117 @@ +/* eslint-disable no-undef */ + +// To run test: +// % yarn test -- -t tApp --verbose + +import { render, screen } from '@testing-library/react'; +import userEvent from '@testing-library/user-event' + + +import { createMemoryHistory } from 'history' +import { Router } from 'react-router-dom' + +import App from '../App'; + +describe('tApp', () => { + + it('should render the home page by default', () => { + + const history = createMemoryHistory() + render( + + + , + ) + + // NavBar + expect(screen.queryByTestId('nav-item-askbuddy')).toBeInTheDocument(); + + // Landing Page + expect(screen.getByText('COVID-19 Buddy: Your Trustworthy Assistant')).toBeInTheDocument() + + // GitHub + expect(screen.queryByTestId('github-container')).toBeInTheDocument(); + + }); + + it('click "Ask Buddy" in navbar should navigate to the Buddy view', async () => { + + const history = createMemoryHistory() + render( + + + , + ); + + const elNavAskBuddy = await screen.findByTestId('nav-item-askbuddy'); + userEvent.click(elNavAskBuddy); + + // Location should be updated + expect(history.location.pathname).toEqual('/askbuddy'); + + // View should be updated to the Ask Buddy mode + expect(screen.queryByTestId('qna-container')).toBeInTheDocument(); + }); +}); + +// ----------- +// Examples of UI interaction tests with puppeteer in jest: +// https://blog.logrocket.com/react-end-to-end-testing-jest-puppeteer/ + +// import puppeteer from "puppeteer"; +// jest.setTimeout(100000); + +// describe('tApp', () => { + +// // https://itnext.io/how-not-to-despair-while-setting-up-puppeteer-and-jest-on-a-create-react-app-plus-ci-on-travis-b25f387ee00f +// // https://blog.logrocket.com/react-end-to-end-testing-jest-puppeteer/ + +// let browser; +// let page; + +// beforeAll(async () => { +// browser = await puppeteer.launch({ +// // headless: false, +// // devtools: true, +// // slowMo: 250, // slow down by 250ms +// }); +// }); + +// beforeEach(async () => { +// page = await browser.newPage(); + +// // % yarn start +// // must be run before this line +// await page.goto('http://localhost:3000'); +// }); + +// afterEach(async () => await page.close()); + +// afterAll(async () => await browser.close()); + +// it('should be loaded properly', +// async () => { + +// // https://developers.google.com/web/tools/puppeteer/debugging + +// await expect(page.title()).resolves.toMatch('COVID-19 Buddy'); + +// // await page.evaluate(() => { +// // debugger; +// // }); + +// } +// ); + +// it('click "Ask Buddy" in navbar', +// async () => { + +// const selector = '[data-testid="nav-item-askbuddy"]'; +// await page.waitForSelector(selector); + +// await page.click(selector); +// const domQNAContainer = await page.$$('[data-testid="qna-container"]'); +// expect(domQNAContainer.length).toBe(1); + +// }); +// }); \ No newline at end of file diff --git a/client/src/__tests__/components/HCPInfo.test.js b/client/src/__tests__/components/HCPInfo.test.js new file mode 100644 index 0000000..de9c32d --- /dev/null +++ b/client/src/__tests__/components/HCPInfo.test.js @@ -0,0 +1,50 @@ +// To run test: +// % yarn test -- -t tHCPInfo --verbose + +import { render, screen } from '@testing-library/react'; +import HCPInfo from '../../components/QnA/HCPInfo'; + +const longLabel = 'address Long Label'; +const testAddressInfo = { + longLabel: longLabel, + postalCode: '01760', + country: 'US' +}; + +const data = { + mainActivity: { + workplace: { + name: 'Workplace name', + address: { + ...testAddressInfo, + city: {label: 'Natick'}, + county: {label: 'MA'} + } + } + }, + otherActivities: [] +}; + +describe('tHCPInfo', () => { + it('Workplace name should be visible', () => { + + const renderResult = render(); + expect(renderResult.getByText(data.mainActivity.workplace.name)).toBeInTheDocument(); + + // screen.debug(); + }); + + it.each([ + ...Object.entries(testAddressInfo), + ['city', 'Natick'], + ['county', 'MA'] + ]) + ('Workplace address should contain appropriate information "%s"', (key, expected) => { + + render(); + + const elWorkplace = screen.getByTestId('data-workplace'); + expect(elWorkplace).toHaveTextContent(expected); + + }); +}); \ No newline at end of file diff --git a/client/src/__tests__/components/Landing.test.js b/client/src/__tests__/components/Landing.test.js new file mode 100644 index 0000000..cdb06b9 --- /dev/null +++ b/client/src/__tests__/components/Landing.test.js @@ -0,0 +1,26 @@ +// To run test: +// % yarn test -- -t tLanding --verbose + +import renderer from 'react-test-renderer'; + + +import HCPContext from '../../store/hcp-context.js'; +import Landing from '../../components/Landing/Landing'; + + +describe('tLanding', () => { + it('Landing page should have an appropriate snapshot', () => { + + const snapshot = renderer + .create( + Mocked getLinkFindHCP + }}> + + ) + .toJSON(); + expect(snapshot).toMatchSnapshot(); + + }); + +}); \ No newline at end of file diff --git a/client/src/__tests__/components/Response.test.js b/client/src/__tests__/components/Response.test.js new file mode 100644 index 0000000..c33c3a4 --- /dev/null +++ b/client/src/__tests__/components/Response.test.js @@ -0,0 +1,60 @@ +// To run test: +// % yarn test -- -t tResponse --verbose + +import { render } from '@testing-library/react'; + +// Mock the 'Suggestion' component before loading the 'Response' component for testing + +const mockedSuggestionText = 'I am a mocked Suggestion!!!'; +jest.mock("../../components/QnA/Suggestion", () => { + const ComponentToMock = () =>

{mockedSuggestionText}

; + return ComponentToMock; +}); + +// eslint-disable-next-line import/first +import Response from '../../components/QnA/Response'; + + +// https://morioh.com/p/0475718676d4 + +describe('tResponse', () => { + it('should show response data', () => { + let curRes = { + id: 10, + specialistsNearMe: { + data: { + coords: [0, 0], + activities: [] + } + } + }; + const renderResult = render(); + expect(renderResult.getByText(mockedSuggestionText)).toBeInTheDocument(); + + // debug document + // screen.debug(); + }); + + it.each([ + ['empty', {}], + ['{id: -1}', {id: -1}] + ])('Error text should be thrown when data is invalid -> "%s"', (text, input) => { + let curRes = input; + const renderResult = render(); + + expect(renderResult.getByText("Something is wrong. Please try again later.")).toBeInTheDocument(); + + // console.log('renderResult: ', renderResult); + // console.log('screen: ', screen); + + // debug document + // screen.debug(); + }); +}); + +// test('renders learn react link', () => { +// let curRes = {}; +// render(); +// // const linkElement = screen.getByText(/learn react/i); +// // expect(linkElement).toBeInTheDocument(); +// }); \ No newline at end of file diff --git a/client/src/__tests__/components/__snapshots__/Landing.test.js.snap b/client/src/__tests__/components/__snapshots__/Landing.test.js.snap new file mode 100644 index 0000000..123f4fa --- /dev/null +++ b/client/src/__tests__/components/__snapshots__/Landing.test.js.snap @@ -0,0 +1,318 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`tLanding Landing page should have an appropriate snapshot 1`] = ` +Array [ +
+

+ COVID-19 Buddy: Your Trustworthy Assistant +

+
+

+ Do you have doubts about COVID-19? Do you need help to make decisions on when to seek medical care? +
+ No worries. COVID-19 Buddy can help you with it! +
+

+

+ Simply chat with the Buddy for assistant or talk to a healthcare provider near you. +

+
+
+ + +
+
, +
+
+
+ +
+
+ Why Getting a COVID-19 Vaccine +
+
+
    +
  • + Help keep you from getting COVID-19 +
  • +
  • + Once you are fully vaccinated, you can start doing more +
  • +
  • + Safer way to help build protection +
  • +
  • + Important tool to help stop the pandemic +
  • +
  • + Vaccines are safe and effective +
  • +
+
+
+
+ For more details, visit +
+ + +
+
+
+
+ +
+
+ When You Are Sick - Monitor your symptoms +
+
+ Symptoms of COVID-19 include +
    +
  • + Fever +
  • +
  • + Cough +
  • +
  • + Shortness of breath +
  • +
  • + ...and more... +
  • +
+ Follow instructions from your healthcare provider and local health department. +
+ +
+
+
+ +
+
+ When to seek emergency medical attention +
+
+ If someone is having +
    +
  • + Trouble breathing +
  • +
  • + Persistent pain or pressure in the chest +
  • +
  • + Inability to wake or stay awake +
  • +
  • + Pale, gray, or blue-colored skin, lips, or nail beds depending on skin tone +
  • +
+
+
+
+ + + + Call + + 911 + + or +
+ +
+
+
+
+ +
+
+ To prevent the spread of COVID-19 +
+
+
    +
  • + Wear a mask +
  • +
  • + Stay at least 6 feet apart from others +
  • +
  • + Wash your hands often +
  • +
  • + Cover your coughs and sneezes +
  • +
  • + Clean high-touch surfaces every day +
  • +
+
+
+
+ For more details, see +
+ +
+
+
+
+
, +] +`; diff --git a/client/src/__tests__/services/HCLSDKService.test.js b/client/src/__tests__/services/HCLSDKService.test.js new file mode 100644 index 0000000..327d095 --- /dev/null +++ b/client/src/__tests__/services/HCLSDKService.test.js @@ -0,0 +1,83 @@ +// To run test: +// % yarn test -- -t tHCLSDKService --verbose + +global.HclAPI = jest.fn(() => ({})); + +// eslint-disable-next-line import/first +import { + defaultSDKConfig, + quickSearchData, + quickSearchSpecialtyCodes, + getLinkLocation, + getSpecialtyCode } + from '../../services/HCLSDKService'; + + +const expQuickSearchData = [ + { + specialtyCode: 'SP.WUS.PD', + specialtyLabel: 'PEDIATRICS' + }, + { + specialtyCode: 'SP.WUS.OBS', + specialtyLabel: 'OBSTETRICS' + }, + { + specialtyCode: 'SP.WUS.P', + specialtyLabel: 'PSYCHIATRY' + } +] + +describe('tHCLSDKService', () => { + + it('defaultSDKConfig should be expected', () => { + + const expDefaultConfig = { + apiKey: expect.anything(), + appName: 'COVID-19 Buddy', + appURL: 'https://covid-buddy.herokuapp.com/' + }; + + expect(defaultSDKConfig).toEqual(expDefaultConfig); + }); + + it('quickSearchData should be expected', () => { + + expect(quickSearchData).toMatchObject(expQuickSearchData); + }); + + it('quickSearchSpecialtyCodes should be expected', () => { + + const expSPCodes = ['SP.WUS.PD', 'SP.WUS.OBS', 'SP.WUS.P']; + + expect(quickSearchSpecialtyCodes).toEqual(expSPCodes); + }); + + it('getLinkLocation should return an expected output', () => { + + const curLocation = { + lat: '123', + lon: '456' + }; + + const workplaceLocation = { + lat: '222', + lon: '333' + }; + + const actLink = getLinkLocation(curLocation, workplaceLocation); + const expLink = `https://www.google.com/maps/dir/${curLocation.lat},${curLocation.lon}/${workplaceLocation.lat},${workplaceLocation.lon}`; + expect(actLink).toEqual(expLink); + }); + + it('getSpecialtyCode should return an expected output', () => { + + const actCode = getSpecialtyCode(expQuickSearchData[0].specialtyLabel); + const expCode = expQuickSearchData[0].specialtyCode; + + expect(actCode).toEqual(expCode); + }); + +}); + + diff --git a/client/src/__tests__/services/QnAService.test.js b/client/src/__tests__/services/QnAService.test.js new file mode 100644 index 0000000..9453aef --- /dev/null +++ b/client/src/__tests__/services/QnAService.test.js @@ -0,0 +1,97 @@ +import axios from 'axios'; +import { + getFAQQuestions, + getFAQResponseById, + getResponse +} + from '../../services/QnAService'; + +jest.mock('axios'); + +describe('tQnAService', () => { + + afterEach(() => { + jest.resetAllMocks(); + }); + + it('getFAQQuestions should fetch an appropriate data', async () => { + + const rawRes = { data: [ + { category: 'mno' }, + { category: 'xyz' }, + { category: 'abc' } + ] }; + axios.get.mockResolvedValue(rawRes); + + // --- Call getFAQQuestions with the default input + + const actRes = await getFAQQuestions(); + + const expRes = [ + { category: 'abc' }, + { category: 'mno' }, + { category: 'xyz' } + ]; + + expect(actRes).toEqual(expRes); + + let category = 'All'; + + const getExpApi = catName => `/getfaqquestions?category=${catName}`; + expect(axios.get).toHaveBeenCalledWith(getExpApi(category)); + + + // --- Call getFAQQuestions with a particular category + jest.resetAllMocks(); + axios.get.mockResolvedValue({ data: [ rawRes.data[1] ] }); + + category = 'mno'; + + const actResWithInput = await getFAQQuestions(category); + + expect(actResWithInput).toEqual([ expRes[1] ]); + expect(axios.get).toHaveBeenCalledWith(getExpApi(category)); + + }); + + it('getFAQResponseById should fetch an appropriate data', async () => { + + const expRes = { data: 'mockedData' }; + axios.get.mockResolvedValue(expRes); + + const myId = 'myId'; + const actRes = await getFAQResponseById(myId); + + expect(actRes).toEqual(expRes.data); + expect(axios.get).toHaveBeenCalledWith(`/getfaqresponse?id=${myId}`); + }); + + it('getResponse should fetch an appropriate data', async () => { + + const expRes = { data: 'mockedData' }; + axios.get.mockResolvedValue(expRes); + + + // --- Call getResponse with a valid query + let myQuery = 'myQuery'; + const actRes = await getResponse(myQuery); + + expect(actRes).toEqual(expRes.data); + + const getExpApi = query => `/getqnaresponse?msg=${query}`; + expect(axios.get).toHaveBeenCalledWith(getExpApi(myQuery)); + + // --- Call getResponse and a reject GET request is called + // An empty array should be returned + + jest.resetAllMocks(); + axios.mockRejectedValue(new Error('Async error')); + + myQuery = 'rejectedRes' + const actResReject = await getResponse(myQuery); + + expect(actResReject).toEqual([]); + expect(axios.get).toHaveBeenCalledWith(getExpApi(myQuery)); + + }); +}); \ No newline at end of file diff --git a/client/src/components/Layout/Layout.js b/client/src/components/Layout/Layout.js index dfad360..388a60d 100644 --- a/client/src/components/Layout/Layout.js +++ b/client/src/components/Layout/Layout.js @@ -38,16 +38,19 @@ const Layout = (props) => { search: ctx.appQueryParams } } + data-testid="nav-item-brand" > - COVID-19 BUDDY + COVID-19 BUDDY