Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jasalisbury committed Nov 8, 2021
1 parent 1fb7bc6 commit b6d4218
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
14 changes: 7 additions & 7 deletions frontend/src/widgets/__tests__/FrequencyGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import userEvent from '@testing-library/user-event';
import { FreqGraph } from '../FrequencyGraph';

const TEST_DATA = {
topic: [
topics: [
{
category: 'first category',
count: 1,
Expand All @@ -23,7 +23,7 @@ const TEST_DATA = {
count: 0,
},
],
reason: [
reasons: [
{
category: 'one',
count: 1,
Expand All @@ -46,22 +46,22 @@ const renderFrequencyGraph = async () => (
describe('Frequency Graph', () => {
it('shows topics by default', async () => {
renderFrequencyGraph();
const topics = await screen.findByText('Topics');
expect(topics).toBeInTheDocument();
const topics = await screen.findByRole('button', { name: 'Open change graph type menu' });
expect(topics.textContent).toBe('Topics');
});

it('can switch to show reasons', async () => {
renderFrequencyGraph();
const topics = await screen.findByText('Topics');
const topics = await screen.findByRole('button', { name: 'Open change graph type menu' });

userEvent.click(topics);
const reasonBtn = await screen.findByText('Reasons');
userEvent.click(reasonBtn);
const apply = await screen.findByText('Apply');
userEvent.click(apply);

const reasons = await screen.findByText('Reasons');
expect(reasons).toBeInTheDocument();
const reasons = await screen.findByRole('button', { name: 'Open change graph type menu' });
expect(reasons.textContent).toBe('Reasons');
});

it('can show accessible data', async () => {
Expand Down
20 changes: 10 additions & 10 deletions src/widgets/frequencyGraph.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,24 @@ describe('frequency graph widget', () => {
id: [reportOne.id, reportTwo.id, reportThree.id, reportFour.id],
}]);

const { topic } = res;
const { topics } = res;

expect(topic.find((r) => r.category === 'Home Visiting').count).toBe(3);
expect(topic.find((r) => r.category === 'Five-Year Grant').count).toBe(2);
expect(topic.find((r) => r.category === 'Fiscal / Budget').count).toBe(2);
expect(topic.find((r) => r.category === 'Nutrition').count).toBe(0);
expect(topics.find((r) => r.category === 'Home Visiting').count).toBe(3);
expect(topics.find((r) => r.category === 'Five-Year Grant').count).toBe(2);
expect(topics.find((r) => r.category === 'Fiscal / Budget').count).toBe(2);
expect(topics.find((r) => r.category === 'Nutrition').count).toBe(0);
});

it('returns count of reasons', async () => {
const res = await frequencyGraph([{
id: [reportOne.id, reportTwo.id, reportThree.id, reportFour.id],
}]);

const { reason } = res;
const { reasons } = res;

expect(reason.find((r) => r.category === 'Change in Scope').count).toBe(3);
expect(reason.find((r) => r.category === 'Complaint').count).toBe(1);
expect(reason.find((r) => r.category === 'Child Incidents').count).toBe(2);
expect(reason.find((r) => r.category === 'Full Enrollment').count).toBe(0);
expect(reasons.find((r) => r.category === 'Change in Scope').count).toBe(3);
expect(reasons.find((r) => r.category === 'Complaint').count).toBe(1);
expect(reasons.find((r) => r.category === 'Child Incidents').count).toBe(2);
expect(reasons.find((r) => r.category === 'Full Enrollment').count).toBe(0);
});
});

0 comments on commit b6d4218

Please sign in to comment.