Skip to content

Commit

Permalink
fix some problems
Browse files Browse the repository at this point in the history
  • Loading branch information
BelousSofiya committed Oct 31, 2023
1 parent c16050c commit 0ccda30
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ const CompanyCard = ({ companyData, isAuthorized }) => {
/>
);
const outlinedStar = (
<StarOutlined className={styles['star']} onClick={handleClick} />
<StarOutlined
className={styles['star']}
onClick={handleClick}
data-testid="emptystar"
/>
);

useEffect(() => {
Expand Down
58 changes: 19 additions & 39 deletions FrontEnd/src/tests/CompanyCard.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
<MemoryRouter>
<CompanyCard isAuthorized={{ isAuth: true }} companyData={company} />
Expand All @@ -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,
Expand All @@ -68,8 +58,8 @@ describe('CompanyCard component unit tests', () => {
});
};

async () => {
await axios.post.mockResolvedValue({
() => {
axios.post.mockResolvedValue({
company_pk: 1,
});

Expand All @@ -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,
Expand All @@ -128,8 +108,8 @@ describe('CompanyCard component unit tests', () => {
});
};

async () => {
await axios.post.mockResolvedValue({
() => {
axios.post.mockResolvedValue({
company_pk: 1,
});

Expand Down
2 changes: 1 addition & 1 deletion FrontEnd/src/tests/CookieModal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
<MemoryRouter>
<CookieMod active={true} />
Expand Down
8 changes: 4 additions & 4 deletions FrontEnd/src/tests/Search.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({});

Check failure on line 27 in FrontEnd/src/tests/Search.test.js

View workflow job for this annotation

GitHub Actions / Linting

'get:' is defined but never used

async () => {
await axios.get.mockResolvedValue({
() => {
axios.get.mockResolvedValue({
data: [
{
id: 1,
Expand Down

0 comments on commit 0ccda30

Please sign in to comment.