Skip to content

Commit

Permalink
Merge pull request #20 from andela/ch-test-hoc-161121591
Browse files Browse the repository at this point in the history
#161121591 Add tests for modules/Hoc folder
  • Loading branch information
Chieze-Franklin committed Oct 17, 2018
2 parents 3b8f9fe + 2f588cd commit 1493347
Show file tree
Hide file tree
Showing 4 changed files with 3,456 additions and 3,406 deletions.
18 changes: 9 additions & 9 deletions client/src/modules/HOC/index.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import React from 'react';
import ReactTooltip from 'react-tooltip';
import CardItem from '../Home/components/CardItem';
import React from "react";
import ReactTooltip from "react-tooltip";
import CardItem from "../Home/components/CardItem";

const renderCards = (addFavorites, { teams }) => {
return teams.map(item => {
const toolTip = item.private ? 'private team' : 'public team';
const lock = item.private ? 'lock' : 'lock_open';
const favorite = item.favorite ? 'red' : 'grey';
const toolTip = item.private ? "private team" : "public team";
const lock = item.private ? "lock" : "lock_open";
const favorite = item.favorite ? "red" : "grey";
let progress = [];
if (item.progress >= 0 && item.progress < 30) {
progress = ['zero', 'zero-bg'];
progress = ["zero", "zero-bg"];
} else if (item.progress >= 30 && item.progress < 70) {
progress = ['half-way', 'half-way-bg'];
progress = ["half-way", "half-way-bg"];
} else {
progress = ['completed', 'completed-bg'];
progress = ["completed", "completed-bg"];
}

return (
Expand Down
11 changes: 11 additions & 0 deletions client/src/tests/modules/hoc/hocMockData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-disable no-undef */

const props = {
item: {},
favorite: "fargo",
lock: "andela",
toolTip: "taps",
isFavorited: true
};

export default props;
39 changes: 39 additions & 0 deletions client/src/tests/modules/hoc/index.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from "react";
import { shallow } from "enzyme";
import renderCards from "../../../modules/HOC";
import mockData from "./hocMockData";

describe("<Test HOC Component />", () => {
it("should mount without crashing", () => {
const addFavorites = jest.fn(3);
const data = {
teams: [
{
private: 'private team',
favorite: 'red',
progress: 25
},
{
private: 'private team',
favorite: 'red',
progress: 65
},
{
private: 'private team',
favorite: 'red',
progress: 244
}
]
};

const props = {
...mockData,
progressBar: data.teams,
addFavorites
};

const ComponentFromHOC = renderCards(addFavorites, data);
const wrapper = shallow(<div><ComponentFromHOC {...props} /></div>);
expect(wrapper).toMatchSnapshot();
});
});
Loading

0 comments on commit 1493347

Please sign in to comment.