-
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
Brenda Rios - Inspiration-board- Octos #22
base: master
Are you sure you want to change the base?
Conversation
Inspiration BoardWhat We're Looking For
|
constructor() { | ||
super(); | ||
|
||
this.state = { | ||
cards: [], | ||
status: { | ||
message: "Successfuly cards loaded!", | ||
type: "success" |
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.
I think we could remove this status
part of the Board
component's state. This is because we're already tracking the status message state in the App
component (and indeed, that's where the data is being used to render the Status
component).
So basically, this bit of state data is redundant and is not currently being used by your code.
const cardsData = response.data.map((card) =>{ | ||
return {text: card.card.text, | ||
emoji: card.card.emoji, | ||
id: card.card.id |
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.
This could probably be simplified to just return card.card;
.
|
||
|
||
card.id = response.data.card.id; | ||
updatedCards.push(card); |
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.
Good use of closures to easily re-use the card data from the form (in the card
variable), to later on add that data into state even though the API did not return a response which included all of the card data.
describe('Card', () => { | ||
test('matches a snapshot', () => { | ||
const wrapper = shallow(<Card id={2} deleteCardCallback={() => {}} />); | ||
expect(wrapper).toMatchSnapshot(); |
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.
This is good, however we could probably include more snapshot tests.
Specifically, we frequently want to have snapshot tests for each of the props that a component receives which have some impact on the visual result. In this case that would be the text
and emoji
props.
Having at least one test for each of those props (and maybe one for when both are set), will help us to cover more possible outcomes from rendering a component. This will in turn help ensure that we don't accidentally break the rendering for some part of the component.
As an example, if we accidentally removed line 25 from Card.js
(<p className="card_content-text">{this.props.text}</p>
) then our card would not render correctly, but this test might continue to pass.
Inspiration Board
Congratulations! You're submitting your assignment!
Comprehension Questions