Skip to content

Commit

Permalink
BUG012 - Adicionando teste
Browse files Browse the repository at this point in the history
  • Loading branch information
oEduardoAfonso committed Jul 26, 2024
1 parent 9a394d8 commit 4d7e16f
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { LineChart } from '@mui/x-charts';
import { Characteristic } from '@customTypes/product';
import { useEffect, useState } from 'react';
import { Box } from '@mui/material';

export interface CurveGraphProps {
planejado: Characteristic[];
Expand Down Expand Up @@ -44,30 +45,35 @@ export default function SimpleLineChart({ planejado, realizado }: CurveGraphProp
if (planned.length !== accomplished.length) {
return (
<div>
<p>O número do resultados das caracteristicas planejadas deve ser igual ao número de realizadas realizadas</p>
<p>O número do resultados das caracteristicas planejadas deve ser igual ao número de realizadas</p>
</div>
);
}

return (
<LineChart
width={700}
height={400}
series={series}
xAxis={[{
scaleType: 'point',
data: labels,
min: 0.0,
max: 1,
tickMinStep: 0,
}]}
yAxis={[
{
scaleType: 'linear',
<Box
display="flex"
alignItems="center"
data-testid="line-chart">
<LineChart
width={700}
height={400}
series={series}
xAxis={[{
scaleType: 'point',
data: labels,
min: 0.0,
max: 1,
},
]}
/>
tickMinStep: 0,
}]}
yAxis={[
{
scaleType: 'linear',
min: 0.0,
max: 1,
},
]}
/>
</Box>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,79 @@ import Release from '../index.page';

jest.mock('@services/product', () => ({
productQuery: {
getReleaseAnalysisDataByReleaseId: jest.fn(),
getReleaseList: jest.fn(),
getCompareGoalAccomplished: jest.fn()
getReleaseAnalysisDataByReleaseId: jest.fn()
}
}));

describe('Release', () => {
it('renders without crashing', async () => {
const startAtDate = '2022-01-01T00:00:00.000Z';
const endAtDate = '2022-04-01T00:00:00.000Z';

const release = {
id: 1,
release_name: 'release name',
created_at: startAtDate,
start_at: startAtDate,
end_at: endAtDate,
goal: {},
accomplished: {}
release_name: 'release name',
description: 'release description',
created_by: 1,
product: 1,
goal: 1,
};
const releaseList = [

const planned = [
{
id: 1,
release_name: 'release name 1',
start_at: startAtDate,
goal: {},
accomplished: {}
name: "reliability",
value: 0.5
},
{
id: 2,
release_name: 'release name 2',
end_at: endAtDate,
goal: {},
accomplished: {}
name: "maintainability",
value: 0.5
}
];
(productQuery.getCompareGoalAccomplished as jest.Mock).mockResolvedValue({ data: [release] });
(productQuery.getReleaseList as jest.Mock).mockResolvedValue({ data: releaseList });
// const props: any = { releaseId: "1", organizationId: "1", productId: "1" };
// const { getByText } = render(<Release {...props} />);

// await act(async () => {
// expect(getByText('release name')).toBeInTheDocument();
// expect(getByText('Selecione a release')).toBeInTheDocument();
// });

const accomplished =
[
{
repository_name: "repository name 1",
characteristics: [
{
name: "reliability",
value: 0.6
}
]
},
{
repository_name: "repository name 2",
characteristics: [
{
name: "reliability",
value: 0.6
},
{
name: "maintainability",
value: 0.5
}
]
}
];

const response = {
release,
planned,
accomplished
};

(productQuery.getReleaseAnalysisDataByReleaseId as jest.Mock).mockResolvedValue({ data: [response] });

await act(async () => {
const { getByText, getAllByTestId } = render(<Release />);

const charts = getAllByTestId('line-chart');
expect(getByText('release name')).toBeInTheDocument();
expect(getByText('O número do resultados das caracteristicas planejadas deve ser igual ao número de realizadas')).toBeInTheDocument();
expect(charts.length).toBe(1);
});
});
});

0 comments on commit 4d7e16f

Please sign in to comment.