Skip to content
This repository was archived by the owner on Jul 1, 2020. It is now read-only.

Replacing div with React Fragment #8

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

krishnaglick
Copy link

Using div means this affects the dom. This could have unintended consequences. Replacing it with React.Fragment (<> shorthand) removes that issue.

Using div means this affects the dom. This could have unintended consequences. Replacing it with React.Fragment (<> shorthand) removes that issue.
@@ -0,0 +1,15 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Snapshots are a great way to enforce tests without manually writing out all the html in each test!

@@ -60,7 +62,8 @@ describe('Client side', () => {
<BadComponent />
</ErrorFallback>)

expect(component.html()).toBe('<div></div>')
expect(component.html()).toBe(null)
expect(component.html()).toMatchSnapshot()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it doesn't render the extra div, we now default to null. This is possibly a breaking change.

@@ -122,7 +126,8 @@ describe('Client side', () => {
</ContextProvider>
)

expect(component.html()).toBe('<div><div>No errors! Context variable</div></div>')
expect(component.html()).toBe('<div>No errors! Context variable</div>')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping these expectations to show things passing, but it'd be awesome to switch solely to snapshots.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant