forked from AdaGold/inspiration-board
-
Notifications
You must be signed in to change notification settings - Fork 43
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
Selam - Ampers #34
Open
SelamawitA
wants to merge
5
commits into
Ada-C9:master
Choose a base branch
from
SelamawitA:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+25,543
−10
Open
Selam - Ampers #34
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e78afce
built and tested Card component, renders as expected.
SelamawitA 143097e
added ability for user to delete a card
SelamawitA 2ebcfe8
added a drop down of emojis
SelamawitA 8dfb17f
snapshots for Board,Card,and CardForm are passing.
SelamawitA 044c80f
updated tests
SelamawitA File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from 'react'; | ||
import Board from './Board'; | ||
import { mount , shallow} from 'enzyme'; | ||
|
||
|
||
describe('Board', () => { | ||
test('that it matches an existing snapshot', () => { | ||
// First Mount the Component in the testing DOM | ||
// Arrange | ||
|
||
const wrapper = mount( <Board | ||
url="https://inspiration-board.herokuapp.com/boards/" | ||
boardName={`Ada-Lovelace`} | ||
/>) | ||
|
||
// Assert that it looks like the last snapshot | ||
expect(wrapper).toMatchSnapshot(); | ||
|
||
// Remove the component from the DOM (save memory and prevent side effects). | ||
wrapper.unmount(); | ||
}); | ||
|
||
test('shallow mount', ()=> { | ||
const cards = shallow( | ||
<Board | ||
url="https://inspiration-board.herokuapp.com/boards/" | ||
boardName={`Ada-Lovelace`} | ||
/> | ||
); | ||
expect(cards).toMatchSnapshot(); | ||
}) | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,20 +2,38 @@ import React, { Component } from 'react'; | |
import PropTypes from 'prop-types'; | ||
import emoji from 'emoji-dictionary'; | ||
|
||
|
||
import './Card.css'; | ||
|
||
function convertToemoji(anEmoji){ | ||
if (anEmoji != null){ | ||
return emoji.getUnicode(anEmoji) | ||
} | ||
} | ||
|
||
|
||
class Card extends Component { | ||
findID = () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not a very great function name, maybe something like just |
||
this.props.deleteCard(this.props.id) | ||
} | ||
|
||
render() { | ||
return ( | ||
<div className="card"> | ||
Card | ||
<section className="card__content"> | ||
<button className="card__delete" onClick={this.findID}>x</button> | ||
<p className="card__content-text">{this.props.text}</p> | ||
<p className="card__content-emoji">{convertToemoji(this.props.emoji)}</p> | ||
</section> | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
Card.propTypes = { | ||
|
||
text:PropTypes.string.isRequired, | ||
emoji:PropTypes.string, | ||
id:PropTypes.number, | ||
}; | ||
|
||
export default Card; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from 'react'; | ||
import Card from './Card'; | ||
import { mount , shallow} from 'enzyme'; | ||
|
||
|
||
describe('Card', () => { | ||
test('that it matches an existing snapshot', () => { | ||
|
||
const wrapper = mount( <Card | ||
text = {"hey, friend"} | ||
emoji = {"heart_eyes"} | ||
deleteCard ={() => {} } | ||
id={1} | ||
/>) | ||
|
||
// Assert that it looks like the last snapshot | ||
expect(wrapper).toMatchSnapshot(); | ||
|
||
// Remove the component from the DOM (save memory and prevent side effects). | ||
wrapper.unmount(); | ||
}); | ||
|
||
test('shallow mount', ()=> { | ||
const aCard = shallow( | ||
<Card | ||
text = {"hey, friend"} | ||
emoji = {"heart_eyes"} | ||
deleteCard ={() => {} } | ||
id={1} | ||
/> | ||
); | ||
expect(aCard).toMatchSnapshot(); | ||
}) | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,78 @@ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import Card from './Card.js' | ||
import emoji from 'emoji-dictionary'; | ||
import './NewCardForm.css'; | ||
|
||
const EMOJI_LIST = ["", "heart_eyes", "beer", "clap", "sparkling_heart", "heart_eyes_cat", "dog"] | ||
|
||
|
||
class NewCardForm extends Component { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. watch your indentation throughout this entire component! |
||
constructor(){ | ||
super(); | ||
this.state ={ | ||
text: '', | ||
emoji: '' | ||
}; | ||
} | ||
|
||
populateDropdown = () =>{ | ||
const popItems = EMOJI_LIST.map((anEmoji) =>{ | ||
return( | ||
<option key={anEmoji} value={anEmoji}>{emoji.getUnicode(anEmoji)}</option> | ||
) | ||
}) | ||
return popItems | ||
} | ||
|
||
onFieldChange = (event) =>{ | ||
const fieldName = event.target.name; | ||
const fieldValue = event.target.value; | ||
const updateState = {}; | ||
updateState[fieldName] = fieldValue; | ||
this.setState(updateState); | ||
} | ||
|
||
clearForm = () => { | ||
this.setState({ | ||
text: '', | ||
emoji: '', | ||
}); | ||
} | ||
|
||
|
||
onFormSubmit = (event) => { | ||
event.preventDefault(); | ||
this.props.addCardcallBack(this.state) | ||
this.clearForm(); | ||
} | ||
|
||
|
||
render(){ | ||
return( | ||
<form className="new-card-form" onSubmit={this.onFormSubmit}> | ||
<div className ="new-card-form__form"> | ||
<label className="new-card-form__form-label" htmlFor="text">Text: </label> | ||
<input className="new-card-form__form-textarea" | ||
name="text" | ||
value={this.state.text} | ||
onChange={this.onFieldChange} | ||
type="text" | ||
/> | ||
</div> | ||
<div className="new-card-form__form"> | ||
<select name="emoji" value={this.state.emoji} onChange={this.onFieldChange}> | ||
{this.populateDropdown()} | ||
</select> | ||
</div> | ||
<input type="submit" value="Add Message" /> | ||
</form> | ||
) | ||
} | ||
|
||
} | ||
|
||
NewCardForm.propTypes = { | ||
addCardcallBack: PropTypes.func.isRequired, | ||
} | ||
export default NewCardForm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react'; | ||
import NewCardForm from './NewCardForm'; | ||
import { mount} from 'enzyme'; | ||
|
||
|
||
describe('NewCardForm', () => { | ||
test('that it matches an existing snapshot', () => { | ||
// First Mount the Component in the testing DOM | ||
// Arrange | ||
const wrapper = mount( <NewCardForm addCardcallBack={() => {} } />); | ||
|
||
|
||
// Assert that it looks like the last snapshot | ||
expect(wrapper).toMatchSnapshot(); | ||
|
||
// Remove the component from the DOM (save memory and prevent side effects). | ||
wrapper.unmount(); | ||
}); | ||
|
||
|
||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
proper camel case would be
convertToEmoji