From 0ccda30d56066f3ec759bed69850dc361ed901db Mon Sep 17 00:00:00 2001 From: Sofia Bilous Date: Tue, 31 Oct 2023 14:45:53 +0200 Subject: [PATCH] fix some problems --- .../search_field/companies/CompanyCard.js | 6 +- FrontEnd/src/tests/CompanyCard.test.js | 58 ++++++------------- FrontEnd/src/tests/CookieModal.test.js | 2 +- FrontEnd/src/tests/Search.test.js | 8 +-- 4 files changed, 29 insertions(+), 45 deletions(-) diff --git a/FrontEnd/src/components/SearchPage/search_field/companies/CompanyCard.js b/FrontEnd/src/components/SearchPage/search_field/companies/CompanyCard.js index 617398036..98a867f3e 100644 --- a/FrontEnd/src/components/SearchPage/search_field/companies/CompanyCard.js +++ b/FrontEnd/src/components/SearchPage/search_field/companies/CompanyCard.js @@ -98,7 +98,11 @@ const CompanyCard = ({ companyData, isAuthorized }) => { /> ); const outlinedStar = ( - + ); useEffect(() => { diff --git a/FrontEnd/src/tests/CompanyCard.test.js b/FrontEnd/src/tests/CompanyCard.test.js index 8a887d4bb..5c82e56ea 100644 --- a/FrontEnd/src/tests/CompanyCard.test.js +++ b/FrontEnd/src/tests/CompanyCard.test.js @@ -7,19 +7,19 @@ afterEach(() => { jest.resetAllMocks(); }); +const company = { + id: 1, + name: 'Testname', + categories: [1, 2], + region: 'Testregion', + founded: 2005, + service_info: 'Testinfo', + address: 'Testadress', + banner_image: '', +}; + describe('CompanyCard component unit tests', () => { test('renders years of experiense', () => { - const company = { - id: 1, - name: 'Testname', - categories: [1, 2], - region: 'Testregion', - founded: 2005, - service_info: 'Testinfo', - address: 'Testadress', - banner_image: '', - }; - render( @@ -30,21 +30,11 @@ describe('CompanyCard component unit tests', () => { }); test('testing stars', () => { - const company = { - id: 1, - name: 'Testname', - categories: [1, 2], - region: 'Testregion', - founded: 2005, - service_info: 'Testinfo', - address: 'Testadress', - banner_image: '', - }; jest.mock('axios'); const axios = require('axios'); - async () => { - await axios.get.mockResolvedValue({ + () => { + axios.get.mockResolvedValue({ results: [ { id: 1, @@ -68,8 +58,8 @@ describe('CompanyCard component unit tests', () => { }); }; - async () => { - await axios.post.mockResolvedValue({ + () => { + axios.post.mockResolvedValue({ company_pk: 1, }); @@ -90,21 +80,11 @@ describe('CompanyCard component unit tests', () => { }); test('testing empty stars', () => { - const company = { - id: 1, - name: 'Testname', - categories: [1, 2], - region: 'Testregion', - founded: 2005, - service_info: 'Testinfo', - address: 'Testadress', - banner_image: '', - }; jest.mock('axios'); const axios = require('axios'); - async () => { - await axios.get.mockResolvedValue({ + () => { + axios.get.mockResolvedValue({ results: [ { id: 2, @@ -128,8 +108,8 @@ describe('CompanyCard component unit tests', () => { }); }; - async () => { - await axios.post.mockResolvedValue({ + () => { + axios.post.mockResolvedValue({ company_pk: 1, }); diff --git a/FrontEnd/src/tests/CookieModal.test.js b/FrontEnd/src/tests/CookieModal.test.js index 8d86e8ab4..a7f375126 100644 --- a/FrontEnd/src/tests/CookieModal.test.js +++ b/FrontEnd/src/tests/CookieModal.test.js @@ -6,7 +6,7 @@ import CookieMod from '../components/cookieacception/CookieMod'; afterEach(cleanup); describe('CookieMod component unit tests', () => { - test('renders agry button', () => { + test('renders agree button', () => { render( diff --git a/FrontEnd/src/tests/Search.test.js b/FrontEnd/src/tests/Search.test.js index 46d08317e..5e79ec790 100644 --- a/FrontEnd/src/tests/Search.test.js +++ b/FrontEnd/src/tests/Search.test.js @@ -22,12 +22,12 @@ describe('Search component unit tests', () => { test('testing search', () => { jest.mock('axios'); - // const axios = require('axios'); + const axios = require('axios', () => { - jest.fn().mockResolvedValue({}); + get: jest.fn().mockResolvedValue({}); - async () => { - await axios.get.mockResolvedValue({ + () => { + axios.get.mockResolvedValue({ data: [ { id: 1,