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

increasing test coverage #1217

Merged
merged 18 commits into from
Nov 16, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
31 changes: 30 additions & 1 deletion src/Components/BidCount/BidCount.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ describe('BidCountComponent', () => {
in_grade_at_skill: 5,
},
};
const stylePropsTrue = {
altStyle: true,
isCondensed: true,
isTandemTwo: true,
};
const stylePropsFalse = {
altStyle: false,
isCondensed: false,
isTandemTwo: false,
};

it('is defined', () => {
const wrapper = shallow(
<BidCount {...props} />,
Expand All @@ -20,11 +31,29 @@ describe('BidCountComponent', () => {

it('is defined when hideLabel is true', () => {
const wrapper = shallow(
<BidCount {...props} />,
<BidCount {...props} hideLabel />,
);
expect(wrapper).toBeDefined();
});

it('properly renders classes on true', () => {
const wrapper = shallow(
<BidCount {...props} {...stylePropsTrue} />,
);
expect(wrapper.find('.bid-count-secondary').exists()).toBe(true);
expect(wrapper.find('.bid-count-condensed').exists()).toBe(true);
expect(wrapper.find('.bid-count-list-tandem').exists()).toBe(true);
});

it('properly renders classes on false', () => {
const wrapper = shallow(
<BidCount {...props} {...stylePropsFalse} />,
);
expect(wrapper.find('.bid-count-secondary').exists()).toBe(false);
expect(wrapper.find('.bid-count-condensed').exists()).toBe(false);
expect(wrapper.find('.bid-count-list-tandem').exists()).toBe(false);
});

it('displays 0 when a prop is not defined', () => {
const bidStatistics = {
total_bids: undefined,
Expand Down
33 changes: 32 additions & 1 deletion src/Components/BidListMessages/Success.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,39 @@ import Success from './Success';
import detailsObject from '../../__mocks__/detailsObject';

describe('Success', () => {
const props = {
client: {
perdet_seq_number: 12345,
name: 'Woodard, Wendy',
},
hideLink: false,
};

it('is defined', () => {
const wrapper = shallow(<Success pos={detailsObject} />);
const wrapper = shallow(<Success pos={detailsObject} {...props} />);
expect(wrapper).toBeDefined();
expect(wrapper.find('Link')
.exists()).toBe(true);
});

it('hides link', () => {
const wrapper = shallow(<Success pos={detailsObject} {...props} hideLink />);
expect(wrapper.find('Link')
.exists()).toBe(false);
});

it('renders public profile link when given perdet', () => {
const wrapper = shallow(<Success pos={detailsObject} {...props} />);
expect(wrapper.find('Link').prop('to')).toBe('/profile/bidtracker/public/12345/');
});

it('renders basic link', () => {
const wrapper = shallow(<Success pos={detailsObject} />);
expect(wrapper.find('Link').prop('to')).toBe('/profile/bidtracker/');
});

it('matches snapshot', () => {
const wrapper = shallow(<Success pos={detailsObject} {...props} />);
expect(toJSON(wrapper)).toMatchSnapshot();
});
});
21 changes: 21 additions & 0 deletions src/Components/BidListMessages/__snapshots__/Success.test.jsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Success matches snapshot 1`] = `
<span>
Test Position
(
00003027
) has been successfully added to Bid List.
<span>
<Link
replace={false}
to="/profile/bidtracker/public/12345/"
>
Go to
Woodard, Wendy's'
Bid Tracker
</Link>
.
</span>
</span>
`;
92 changes: 86 additions & 6 deletions src/Components/SavedSearchPillList/SavedSearchPillList.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ import toJSON from 'enzyme-to-json';
import SavedSearchPillList from './SavedSearchPillList';

describe('FavoriteContentComponent', () => {
// const pills = ['1', '0A', 'Projected Vacancy', 'Los Angeles, CA United States of America'];
elizabeth-jimenez marked this conversation as resolved.
Show resolved Hide resolved
const pills = [
{
description: '1',
isCommon: true,
},
{
description: 'Tandem',
isCommon: true,
isCommon: false,
isToggle: true,
},
{
Expand All @@ -21,7 +20,9 @@ describe('FavoriteContentComponent', () => {
];
const props = {
isProjectedVacancy: true,
isTandemSearch: true,
};

it('is defined', () => {
const wrapper = shallow(
<SavedSearchPillList
Expand All @@ -48,10 +49,89 @@ describe('FavoriteContentComponent', () => {
/>,
);
expect(wrapper).toBeDefined();
expect(wrapper.find('div').at(0).children().find('div')
.at(0)
.text())
.toBe('Projected Vacancy');
expect(wrapper.find('div').children().find('div').text()).toBe('Projected Vacancy');
expect(wrapper.find('div').children().find('div')
.find('.saved-search-pill')
.find('.pill--projected-vacancy')
.find('.pill--highlight')
.exists()).toBe(true);
});

it('shows just AP pill when length is 0 and not isProjectedVacancy', () => {
const wrapper = shallow(
<SavedSearchPillList
pills={[]}
isTandemSearch
isProjectedVacancy={false}
/>,
);
expect(wrapper).toBeDefined();
expect(wrapper.find('div').children().find('div').text()).toBe('Available Position');
expect(wrapper.find('div').children().find('div')
.find('.saved-search-pill')
.exists()).toBe(true);
});

it('pill classes render properly when isTandemSearch and isProjectedVacancy', () => {
const wrapper = shallow(
<SavedSearchPillList
pills={pills}
{...props}
/>,
);
expect(wrapper.find('div').children().find('div')).toHaveLength(3);

expect(wrapper.find('div').children().find('div').at(0)
.find('.pill--projected-vacancy')
.exists()).toBe(true);
expect(wrapper.find('div').children().find('div').at(1)
.find('.pill--tandem-search')
.exists()).toBe(true);
expect(wrapper.find('div').children().find('div').at(2)
.find('.pill--tandem2')
.exists()).toBe(true);
});

it('pill classes render properly when isTandemSearch and not isProjectedVacancy', () => {
const wrapper = shallow(
<SavedSearchPillList
pills={pills}
isProjectedVacancy={false}
isTandemSearch
/>,
);
expect(wrapper.find('div').children().find('div')).toHaveLength(3);

expect(wrapper.find('div').children().find('div').at(0)
.find('.pill--projected-vacancy')
.exists()).toBe(false);
expect(wrapper.find('div').children().find('div').at(1)
.find('.pill--tandem-search')
.exists()).toBe(true);
expect(wrapper.find('div').children().find('div').at(2)
.find('.pill--tandem2')
.exists()).toBe(true);
});

it('pill classes render properly when not isTandemSearch and not isProjectedVacancy', () => {
const wrapper = shallow(
<SavedSearchPillList
pills={pills}
isProjectedVacancy={false}
isTandemSearch={false}
/>,
);
expect(wrapper.find('div').children().find('div')).toHaveLength(3);

expect(wrapper.find('div').children().find('div').at(0)
.find('.pill--projected-vacancy')
.exists()).toBe(false);
expect(wrapper.find('div').children().find('div').at(1)
.find('.pill--tandem-search')
.exists()).toBe(false);
expect(wrapper.find('div').children().find('div').at(2)
.find('.pill--tandem2')
.exists()).toBe(false);
});

it('matches snapshot', () => {
Expand Down