Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ package-lock.json
npm-debug.log
.env
dist
pull-request.md
pull-request.md
coverage
2 changes: 2 additions & 0 deletions client/__mocks__/fileMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module.exports = 'test-file-stub';

2 changes: 2 additions & 0 deletions client/__mocks__/styleMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module.exports = {};

36 changes: 36 additions & 0 deletions client/__tests__/ItemCardTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react'
import Adapter from 'enzyme-adapter-react-16';

import {shallow, configure} from 'enzyme'
import ItemCard from '../components/ItemCard'
import {Link} from 'react-router-dom'

configure({ adapter: new Adapter() })

const props = {

item : {
_id: "id",
category: "c",
description: "d",
image : "i",
status: "s",
title : 't'
}
}

describe('Item Card', () => {
it('renders Link', () => {
const wrapper = shallow(<ItemCard {...props}/>);

expect(wrapper.containsMatchingElement(Link)).toEqual(true);
});

it('has immediate children', ()=> {
const wrapper = shallow(<ItemCard {...props}/>);

expect(wrapper.find('.card-body')).toHaveLength(1);
expect(wrapper.find('div.card-img-container')).toHaveLength(1);
expect(wrapper.children()).toHaveLength(2);
})
});
Empty file.
87 changes: 87 additions & 0 deletions client/__tests__/SignUpTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import React from 'react'
import Adapter from 'enzyme-adapter-react-16';

import {shallow, mount, configure} from 'enzyme'
import SignUp from '../components/SignUp'


const props = {
props :{

isLoggedIn: false,
allItems: [],
email: '',
points: '',
firstName: '',
lastName: '',
password: '',
street: '',
street2: '',
city: '',
state: '',
zipCode: '',
latitude: null,
longitude: null,
title: '',
description: '',
category: '',
image: '',
status: false,
user_id: '',
redirect: null,
}

}



configure({ adapter: new Adapter() })


describe('Sign Up', () => {
it('exists', () => {
const wrapper = shallow(<SignUp {...props}/>);

expect(wrapper.find('.container loginAndSignUp')).toHaveLength(0);
});

it('handles Change', () => {
const onChange = jest.fn(),
props ={

isLoggedIn: false,
allItems: [],
email: '',
points: '',
firstName: '',
lastName: '',
password: '',
street: '',
street2: '',
city: '',
state: '',
zipCode: '',
latitude: null,
longitude: null,
title: '',
description: '',
category: '',
image: '',
status: false,
user_id: '',
redirect: null,
handleChange: onChange,
handleSignUpSubmit: onChange,
onChange
}
const SignUpComponent = mount(<SignUp {...props}/>).find('input')
console.log(SignUpComponent)
SignUpComponent.forEach((e) => {
console.log('e',e)
e.simulate('change', { target: {email: '2018-01-22'} })})

expect(onChange).toHaveBeenCalledWith('22.01.2018');

})

});
12 changes: 4 additions & 8 deletions client/components/ItemCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,16 @@ import { NavLink, Link } from 'react-router-dom';
import '../scss/app.scss';

// eslint-disable-next-line react/prefer-stateless-function
class ItemCard extends Component {
constructor(props) {
super(props);
}
// eslint-disable-next-line lines-between-class-members
render() {
const ItemCard = (props)=>{

const {
_id,
category,
description,
image,
status,
title,
} = this.props.item;
} = props.item;

return (
<div>
Expand Down Expand Up @@ -45,6 +41,6 @@ class ItemCard extends Component {
</div>
);
}
}


export default ItemCard;
12 changes: 12 additions & 0 deletions coverage/clover.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<coverage generated="1600987001008" clover="3.2.0">
<project timestamp="1600987001008" name="All files">
<metrics statements="3" coveredstatements="3" conditionals="2" coveredconditionals="1" methods="1" coveredmethods="1" elements="6" coveredelements="5" complexity="0" loc="3" ncloc="3" packages="1" files="1" classes="1"/>
<file name="ItemCard.jsx" path="/Users/kevinfey/Desktop/codesmith/GenerocityCommunity/client/components/ItemCard.jsx">
<metrics statements="3" coveredstatements="3" conditionals="2" coveredconditionals="1" methods="1" coveredmethods="1"/>
<line num="7" count="1" type="stmt"/>
<line num="16" count="1" type="stmt"/>
<line num="18" count="1" type="stmt"/>
</file>
</project>
</coverage>
2 changes: 2 additions & 0 deletions coverage/coverage-final.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{"/Users/kevinfey/Desktop/codesmith/GenerocityCommunity/client/components/ItemCard.jsx": {"path":"/Users/kevinfey/Desktop/codesmith/GenerocityCommunity/client/components/ItemCard.jsx","statementMap":{"0":{"start":{"line":7,"column":17},"end":{"line":43,"column":3}},"1":{"start":{"line":16,"column":8},"end":{"line":16,"column":18}},"2":{"start":{"line":18,"column":4},"end":{"line":42,"column":6}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":7,"column":17},"end":{"line":7,"column":18}},"loc":{"start":{"line":7,"column":26},"end":{"line":43,"column":3}},"line":7}},"branchMap":{"0":{"loc":{"start":{"line":32,"column":24},"end":{"line":32,"column":45}},"type":"cond-expr","locations":[{"start":{"line":32,"column":33},"end":{"line":32,"column":37}},{"start":{"line":32,"column":40},"end":{"line":32,"column":45}}],"line":32}},"s":{"0":1,"1":1,"2":1},"f":{"0":1},"b":{"0":[1,0]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"484321302715b917dfb3e069a39e0e3e1f6fcb63"}
}
Loading