-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Alteração em JSX #2646
Open
tecnicorikardo
wants to merge
1
commit into
mate-academy:master
Choose a base branch
from
tecnicorikardo: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.
Open
Alteração em JSX #2646
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,17 @@ | ||
// export const Person = ({ person }) => (); | ||
import React from 'react'; | ||
|
||
export function Person({ person }) { | ||
return ( | ||
<div> | ||
<p className="Person__name">My name is {person.name}</p> | ||
{person.age && <p className="Person__age">I am {person.age}</p>} | ||
<p className="Person__partner"> | ||
{person.isMarried | ||
? `${person.partnerName} is my ${person.sex === 'm' ? 'wife' : 'husband'}` | ||
: 'I am not married'} | ||
</p> | ||
<p className="Person__greeting">Hello, my name is {person.name} and I am {person.age || 'unknown'} years old.</p> {/* Informação adicional */} | ||
</div> | ||
); | ||
} |
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,8 +1,9 @@ | ||
import React from 'react'; | ||
import { mount } from '@cypress/react18'; | ||
import { Person } from './Person'; | ||
|
||
describe('Person', () => { | ||
describe('', () => { | ||
describe('when person is male', () => { | ||
beforeEach(() => { | ||
const misha = { | ||
name: 'Misha', | ||
|
@@ -11,24 +12,23 @@ describe('Person', () => { | |
isMarried: true, | ||
partnerName: 'Natasha', | ||
}; | ||
|
||
mount(<Person person={misha} />); | ||
}); | ||
|
||
it('should print a name', () => { | ||
cy.get('.Person__name').should('have.text', 'My name is Misha'); | ||
}); | ||
|
||
it('should print an age', () => { | ||
cy.get('.Person__age').should('have.text', 'I am 37'); | ||
}); | ||
|
||
it('should print a partner', () => { | ||
cy.get('.Person__partner').should('have.text', 'Natasha is my wife'); | ||
}); | ||
it('should print a greeting message', () => { // Informação adicional | ||
cy.get('.Person__greeting').should('have.text', 'Hello, my name is Misha and I am 37 years old.'); | ||
}); | ||
}); | ||
|
||
describe('', () => { | ||
describe('when person is female', () => { | ||
it('should show partner as a husband when the person is female', () => { | ||
const olya = { | ||
name: 'Olya', | ||
|
@@ -37,12 +37,9 @@ describe('Person', () => { | |
isMarried: true, | ||
partnerName: 'Maksym', | ||
}; | ||
|
||
mount(<Person person={olya} />); | ||
|
||
cy.get('.Person__partner').should('have.text', 'Maksym is my husband'); | ||
}); | ||
|
||
it('should show correct message if a person is not married', () => { | ||
const tanya = { | ||
name: 'Tanya', | ||
|
@@ -51,21 +48,16 @@ describe('Person', () => { | |
isMarried: false, | ||
partnerName: 'Some Partner', | ||
}; | ||
|
||
mount(<Person person={tanya} />); | ||
|
||
cy.get('.Person__partner').should('contain.text', 'not married'); | ||
}); | ||
|
||
it('should not show age if age is omitted', () => { | ||
const sasha = { | ||
name: 'Sasha', | ||
sex: 'f', | ||
isMarried: false, | ||
}; | ||
|
||
mount(<Person person={sasha} />); | ||
|
||
cy.get('.Person__age').should('not.exist'); | ||
Comment on lines
54
to
61
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. The test case checks that the |
||
}); | ||
}); | ||
|
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.
Consider adding a check to ensure
person.partnerName
is defined before using it. This will prevent potential errors ifpartnerName
is undefined. You can use a conditional check similar to howperson.age
is handled.