Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Unit Tests for VacancyStatus.js #399

Merged
merged 2 commits into from
Jan 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 111 additions & 0 deletions src/components/UI/VacancyStatus/VacancyStatus.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import React from 'react';
import { render } from '@testing-library/react';
import VacancyStatus from './VacancyStatus';

// Mock window.matchMedia
beforeEach(() => {
window.matchMedia = window.matchMedia || function () {
return {
matches: false,
addListener: function () { },
removeListener: function () { }
};
};
});

describe('VacancyStatus Component', () => {
// Mock window.matchMedia
beforeEach(() => {
window.matchMedia = window.matchMedia || function () {
return {
matches: false,
addListener: function () { },
removeListener: function () { }
};
};
});

describe('VacancyStatus Component', () => {
it('renders without crashing', () => {
const { container } = render(<VacancyStatus state="Triage" />);
expect(container).toBeInTheDocument();
});

it('displays the correct step for Triage', () => {
const { getByText } = render(<VacancyStatus state="Triage" />);
expect(getByText('Triage')).toBeInTheDocument();
});

it('displays the correct step for Chair Triage', () => {
const { getByText } = render(<VacancyStatus state="Chair Triage" />);
expect(getByText('Triage')).toBeInTheDocument();
});

it('displays the correct step for Individual Scoring in Progress', () => {
const { getByText } = render(<VacancyStatus state="Individual Scoring in Progress" />);
expect(getByText('Individual Scoring')).toBeInTheDocument();
});

it('displays the correct step for Individual Scoring Complete', () => {
const { getByText } = render(<VacancyStatus state="Individual Scoring Complete" />);
expect(getByText('Individual Scoring')).toBeInTheDocument();
});

it('displays the correct step for Committee Review in Progress', () => {
const { getByText } = render(<VacancyStatus state="Committee Review in Progress" />);
expect(getByText('Committee Review')).toBeInTheDocument();
});

it('displays the correct step for Committee Review Complete', () => {
const { getByText } = render(<VacancyStatus state="Committee Review Complete" />);
expect(getByText('Committee Review')).toBeInTheDocument();
});

it('displays the correct step for Voting Complete', () => {
const { getByText } = render(<VacancyStatus state="Voting Complete" />);
expect(getByText('Voting Complete')).toBeInTheDocument();
});

it('sets the correct current step for Triage', () => {
const { container } = render(<VacancyStatus state="Triage" />);
const steps = container.querySelectorAll('.ant-steps-item');
expect(steps[0]).toHaveClass('ant-steps-item-active');
});

it('sets the correct current step for Chair Triage', () => {
const { container } = render(<VacancyStatus state="Chair Triage" />);
const steps = container.querySelectorAll('.ant-steps-item');
expect(steps[0]).toHaveClass('ant-steps-item-active');
});

it('sets the correct current step for Individual Scoring in Progress', () => {
const { container } = render(<VacancyStatus state="Individual Scoring in Progress" />);
const steps = container.querySelectorAll('.ant-steps-item');
expect(steps[1]).toHaveClass('ant-steps-item-active');
});

it('sets the correct current step for Individual Scoring Complete', () => {
const { container } = render(<VacancyStatus state="Individual Scoring Complete" />);
const steps = container.querySelectorAll('.ant-steps-item');
expect(steps[1]).toHaveClass('ant-steps-item-active');
});

it('sets the correct current step for Committee Review in Progress', () => {
const { container } = render(<VacancyStatus state="Committee Review in Progress" />);
const steps = container.querySelectorAll('.ant-steps-item');
expect(steps[2]).toHaveClass('ant-steps-item-active');
});

it('sets the correct current step for Committee Review Complete', () => {
const { container } = render(<VacancyStatus state="Committee Review Complete" />);
const steps = container.querySelectorAll('.ant-steps-item');
expect(steps[2]).toHaveClass('ant-steps-item-active');
});

it('sets the correct current step for Voting Complete', () => {
const { container } = render(<VacancyStatus state="Voting Complete" />);
const steps = container.querySelectorAll('.ant-steps-item');
expect(steps[3]).toHaveClass('ant-steps-item-active');
});
});
});
Loading