Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8f4b853
Skip tests beyond iteration zero
Nov 26, 2018
ea6d65a
Create DistrictRepository constructor, add cleanStats method. Passin…
Nov 26, 2018
c118d27
Add findByName method, passing first test in iteration1
Nov 26, 2018
674666a
Update findByName to include match of parameter to this.stats, and ch…
Nov 26, 2018
0c72cd6
Update findByName and cleanStats to return case insensitive, next two…
Nov 27, 2018
2f09535
Update cleanStats to correctly compile district object to include all…
Nov 27, 2018
4fb00ed
Update cleanStats to round data to thousands place. passing next test
Nov 27, 2018
4c6e392
Merge pull request #1 from saraebbers/Iteration1
saraebbers Nov 27, 2018
452b2ad
Update cleanStats roundedData to default to 0 if no number
Nov 27, 2018
2eaf3a3
Merge pull request #2 from saraebbers/Iteration1
saraebbers Nov 27, 2018
4efdff9
Add findAllMatches method, passing test one of iteration1 part2
Nov 27, 2018
0aaa04c
Update findAllMatches to return an array with matching search info
Nov 27, 2018
ee71c83
Update findAllMatches to return Arrays that are empty, all inclusive …
Nov 27, 2018
b4511b8
Merge pull request #3 from saraebbers/Iteration1
saraebbers Nov 27, 2018
68dcc77
Create files for components, Create App Component, populate anticipat…
Nov 27, 2018
40ab7ad
Create CardContainer Component with anticipated imports and return jsx
Nov 27, 2018
33861b1
Create ComparisonContainer Component with anticipated imports and ret…
Nov 27, 2018
c10d304
Create Search Component with anticipated imports and return jsx
Nov 27, 2018
c7100b5
Create Card Component with anticipated imports and return jsx
Nov 27, 2018
f15bade
Add ComponentDidMount and prepareDataForDisplay methods to App.js
Nov 28, 2018
0a9c478
Correct findAllMatches in helper file, so stats could be rendered. C…
Nov 29, 2018
789039d
Add Css styling to cardContainer and Card, add logic to display stats…
Nov 29, 2018
463edd5
Adjust Css for displaying data on cards, begin testing for CardContainer
Nov 30, 2018
b941cbd
Add Snapshot tests to components
Nov 30, 2018
69282c2
Merge pull request #4 from saraebbers/Iteration1
saraebbers Nov 30, 2018
55ec12c
Correct proptype, add snapshot test to search
Nov 30, 2018
c2b96e9
Add setupTests file
Nov 30, 2018
64afa82
Correct unique id, add test for App
Dec 1, 2018
1878814
Test for PrepareData for display passing
Dec 2, 2018
0df9628
Search functionality now working, refactored findAllMatches to achiev…
Dec 2, 2018
307b40d
Add proptypes to search component
Dec 2, 2018
57c4243
Add styling to Search, make search search on change and submit
Dec 2, 2018
0bbbce7
Merge pull request #5 from saraebbers/testing
saraebbers Dec 2, 2018
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
13,687 changes: 13,687 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,25 @@
"name": "headcount",
"version": "0.1.0",
"private": true,
"homepage": "https://saraebbers.github.io/headcount2.0",
"devDependencies": {
"enzyme-adapter-react-16": "^1.7.0",
"react-scripts": "1.1.0"
},
"dependencies": {
"enzyme": "^3.7.0",
"gh-pages": "^2.0.1",
"prop-types": "^15.6.2",
"react": "^16.2.0",
"react-dom": "^16.2.0"
"react-dom": "^16.2.0",
"save-dev": "^2.0.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"deploy": "gh-pages -d build",
"predeploy": "npm run build",
"eject": "react-scripts eject"
}
}
11 changes: 10 additions & 1 deletion src/App.css
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
/*APP COMPONENT RELATED CSS GOES HERE*/
*, *:before, *:after {
box-sizing: border-box;
}

.app {
text-align: center;
color: cornflowerblue;
}


43 changes: 42 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,51 @@
import React, { Component } from 'react';
import './App.css';
import Search from './Search';
import ComparisonContainer from './ComparisonContainer';
import CardContainer from './CardContainer';
import DistrictRepository from './helper';
import Kindergartner from './data/kindergartners_in_full_day_program.js';

class App extends Component {
constructor() {
super();
this.state = {
dataSet: 'Kindergartner',
displayData: [],
searchWord: '',
repository: new DistrictRepository(Kindergartner)
}
}

componentDidMount() {
this.prepareDataForDisplay();
}

searchForDistrict = (searchString) => {
const searchWord = searchString;
this.setState( { searchWord } );
this.prepareDataForDisplay(searchString)
}

prepareDataForDisplay = (searchWord) => {
const displayData = this.state.repository.findAllMatches(searchWord);
this.setState({ displayData })
}

render() {

const { cleanData, displayData, dataSet } = this.state;

return (
<div>Welcome To Headcount 2.0</div>
<div>
<h1 className='app'>Welcome To Headcount 2.0</h1>
<Search
searchForDistrict={this.searchForDistrict } />
<ComparisonContainer />
<CardContainer
displayData={ displayData }
dataSet={ dataSet }/>
</div>
);
}
}
Expand Down
74 changes: 70 additions & 4 deletions src/App.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,74 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import { shallow } from 'enzyme';

it('renders without crashing', () => {
const div = document.createElement('div');
// ReactDOM.render(<App />, div);
});

describe('App', () => {
it('Matches the snapshot', () => {
const wrapper = shallow(<App />);
expect(wrapper).toMatchSnapshot;
});

it.skip('componentDidMount calls the method prepareDataForDisplay with the correct params', () => {
const wrapper = shallow(<App />);

});

it.skip('PrepareDataForDisplay calls findAllMatches on the repository held in state', () => {

});

it('PrepareDataForDisplay sets the displayData of state', () => {
let mockDistrictRepository = {
stats: [
{
"Location": "VIRGINIA",
"TimeFrame": 1909,
"DataFormat": "Percent",
"Data": 0.107
},
{
"Location": "VIRGINIA",
"TimeFrame": 3999,
"DataFormat": "Percent",
"Data": 5.999
},
{
"Location": "NorthCarolina",
"TimeFrame": 1999,
"DataFormat": "Percent",
"Data": 1.007
},
{
"Location": "NorthCarolina",
"TimeFrame": 2099,
"DataFormat": "Percent",
"Data": 1.999
}],
findAllMatches: jest.fn(() => {
return [{location: 'NorthCarolina',
stats: {1999: 0.007, 2099: 1.999 }},
{location: 'VIRGINIA',
stats: {1909: 0.107, 3999: 5.999 }}]
})
};

const expected = [{location: 'NorthCarolina',
stats: {1999: 0.007, 2099: 1.999 }},
{location: 'VIRGINIA',
stats: {1909: 0.107, 3999: 5.999 }}]
const wrapper = shallow(<App />);

wrapper.setState({
dataSet: 'College',
displayData: [],
searchWord: '',
repository: mockDistrictRepository
});
wrapper.instance().prepareDataForDisplay();
expect(wrapper.state('displayData')).toEqual(expected);
})


})
40 changes: 40 additions & 0 deletions src/Card.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.above {
color: green;
}

.below {
color: red;
}

.card {
border: solid 2px black;
color: black;
}

ul {
list-style: none;
margin: 0;
padding-left: 30px;
padding-bottom: 10px
}

li {
text-orientation: left;
}

span {
display: flex;
justify-content: space-between;
}

h5 {
padding: 10px;
margin: 5px;
}

.select-btn {
padding: 2px;
border-radius: 25%;
margin: 5px;
font-size: 0.25rem;
}
29 changes: 29 additions & 0 deletions src/Card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import './Card.css'

const Card = ( {location, stats} ) => {
const displayStats = Object.keys(stats).map(stat => {
return ( <li className={`listedStats ${stats[stat] < 0.5 ? 'below' : 'above'}`}> {`${stat}: ${stats[stat] }`}</li>
)
})

return(
<div className='card'>
<span>
<h5>{ location }</h5>
<button className='select-btn'>Select</button>
</span>
<ul>
{displayStats}
</ul>
</div>
)
}

Card.propTypes = {
location: PropTypes.string.isRequired,
stats: PropTypes.object.isRequired
}

export default Card;
22 changes: 22 additions & 0 deletions src/Card.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';
import Card from './Card';
import { shallow } from 'enzyme';

describe('Card', () => {
it('matches the snapshot', () => {

let wrapper = shallow(<Card
key={Date.now()}
location={'string'}
stats={{1909: 0.107, 3999: 5.999}} />);
expect(wrapper).toMatchSnapshot()
});

it.skip('assigns a classNames of listedStats and above to all stats that are above 0.5, and listedStats below to all stats less than 0.5', () => {


})



})
15 changes: 15 additions & 0 deletions src/CardContainer.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.cardContainer-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
grid-gap: 15px;
padding: 10px;
margin: 10px;
border-radius: 25px;
border: cornflowerblue;
align-items: center;
}

.cardContainerHeading {
color: cornflowerblue;
text-align: center;
}
30 changes: 30 additions & 0 deletions src/CardContainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react';
import Card from './Card';
import PropTypes from 'prop-types';
import './CardContainer.css';


const CardContainer = ( {displayData, dataSet} ) => {


const cards = displayData.map(district => {
return <Card
key={`card ${district.location}`}
{...district} />
})

return(
<div>
<h3 className='cardContainerHeading'>{dataSet} data for each district is listed below when nothing is entered in the search field, otherwise, only districts that match the search criteria are listed.</h3>
<section className='cardContainer-grid'>
{ cards }
</section>
</div>
)
}

CardContainer.propTypes = {
displayData: PropTypes.array.isRequired
}

export default CardContainer;
39 changes: 39 additions & 0 deletions src/CardContainer.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react';
import CardContainer from './CardContainer';
import { shallow } from 'enzyme';
import Card from './Card';

describe('CardContainer', () => {
it('matches the snapshot', () => {
let mockDataSet = 'College';
let mockDisplayData =
[{location: 'NorthCarolina',
stats: {1999: 0.007, 2099: 1.999 }},
{location: 'VIRGINIA',
stats: {1909: 0.107, 3999: 5.999 }}];
let wrapper = shallow(<CardContainer displayData={mockDisplayData}
dataSet={mockDataSet}/>);

expect(wrapper).toMatchSnapshot()
});

it('renders all the cards', () => {
let mockDataSet = 'College';
let mockDisplayData =
[ {location: 'NorthCarolina',
stats: {1999: 0.007, 2099: 1.999 }},
{location: 'VIRGINIA',
stats: {1909: 0.107, 3999: 5.999 }}];

let wrapper = shallow(<CardContainer
displayData={ mockDisplayData }
dataSet={mockDataSet} />)
expect(wrapper.find(Card).length).toEqual(2)
});

it.skip('Assigns a unique key to each card', () => {


});

})
13 changes: 13 additions & 0 deletions src/ComparisonContainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
import Card from './Card';

const ComparisonContainer = () => {

return(
<div>
<h3>Select two districts to compare, they will be displayed here.</h3>
</div>
)
}

export default ComparisonContainer;
12 changes: 12 additions & 0 deletions src/ComparisonContainer.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import ComparisonContainer from './ComparisonContainer';
import { shallow } from 'enzyme';

describe('ComparisonContainer', () => {

it('matches the snapshot', () => {
const wrapper = shallow(<ComparisonContainer />);
expect(wrapper).toMatchSnapshot()
});

})
Loading