This repository was archived by the owner on Jul 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Replacing div with React Fragment #8
Open
krishnaglick
wants to merge
3
commits into
zekchan:master
Choose a base branch
from
krishnaglick:patch-1
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
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 hidden or 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,15 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`Client side Renders child component with context dependencies 1`] = `"<div>No errors! Context variable</div>"`; | ||
|
|
||
| exports[`Client side Renders child component with legacy context dependencies 1`] = `"<div>No errors! Context variable</div>"`; | ||
|
|
||
| exports[`Client side Renders child component with multiple contexts dependencies 1`] = `"<div>No errors! Context variable1 Context variable2 Context variable3</div>"`; | ||
|
|
||
| exports[`Client side Renders child component without errors 1`] = `"<div>No errors!</div>"`; | ||
|
|
||
| exports[`Client side Renders fallBack component if children rendering throws error 1`] = `"<div>FallBack!</div>"`; | ||
|
|
||
| exports[`Client side Renders fallBack component if children rendering throws error with contexts 1`] = `"<div>FallBack!</div>"`; | ||
|
|
||
| exports[`Client side Renders nothing when children rendering throws error and no fallBack provided 1`] = `null`; | ||
This file contains hidden or 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,11 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`Server side Renders child component with context dependencies 1`] = `"<div><div>No errors! Context variable</div></div>"`; | ||
|
|
||
| exports[`Server side Renders child component with multiple new context dependencies 1`] = `"<div><div>No errors! Context variable1 Context variable2 Context variable3</div></div>"`; | ||
|
|
||
| exports[`Server side Renders child component without errors 1`] = `"<div><div>No errors!</div></div>"`; | ||
|
|
||
| exports[`Server side Renders fallBack component if children rendering throws error 1`] = `"<div>FallBack!</div>"`; | ||
|
|
||
| exports[`Server side Renders fallBack component if children rendering throws error with new contexts 1`] = `"<div>FallBack!</div>"`; |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -33,7 +33,8 @@ describe('Client side', () => { | |
| <GoodComponent /> | ||
| </ErrorFallback>) | ||
|
|
||
| expect(component.html()).toBe('<div><div>No errors!</div></div>') | ||
| expect(component.html()).toBe('<div>No errors!</div>') | ||
| expect(component.html()).toMatchSnapshot() | ||
| }) | ||
|
|
||
| it('Renders fallBack component if children rendering throws error', () => { | ||
|
|
@@ -46,7 +47,8 @@ describe('Client side', () => { | |
| <BadComponent /> | ||
| </ErrorFallback>) | ||
|
|
||
| expect(component.html()).toBe('<div><div>FallBack!</div></div>') | ||
| expect(component.html()).toBe('<div>FallBack!</div>') | ||
| expect(component.html()).toMatchSnapshot() | ||
| turnOnErrors() | ||
| }) | ||
|
|
||
|
|
@@ -60,7 +62,8 @@ describe('Client side', () => { | |
| <BadComponent /> | ||
| </ErrorFallback>) | ||
|
|
||
| expect(component.html()).toBe('<div></div>') | ||
| expect(component.html()).toBe(null) | ||
| expect(component.html()).toMatchSnapshot() | ||
|
Author
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. Since it doesn't render the extra div, we now default to null. This is possibly a breaking change. |
||
| turnOnErrors() | ||
| }) | ||
|
|
||
|
|
@@ -92,7 +95,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>') | ||
| expect(component.html()).toMatchSnapshot() | ||
| }) | ||
|
|
||
| it('Renders child component with context dependencies', () => { | ||
|
|
@@ -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>') | ||
|
Author
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. Keeping these expectations to show things passing, but it'd be awesome to switch solely to snapshots. |
||
| expect(component.html()).toMatchSnapshot() | ||
| }) | ||
|
|
||
| it('Renders child component with multiple contexts dependencies', () => { | ||
|
|
@@ -168,7 +173,8 @@ describe('Client side', () => { | |
| </ContextProvider> | ||
| ) | ||
|
|
||
| expect(component.html()).toBe('<div><div>No errors! Context variable1 Context variable2 Context variable3</div></div>') | ||
| expect(component.html()).toBe('<div>No errors! Context variable1 Context variable2 Context variable3</div>') | ||
| expect(component.html()).toMatchSnapshot() | ||
| }) | ||
|
|
||
| it('Renders fallBack component if children rendering throws error with contexts', () => { | ||
|
|
@@ -203,7 +209,8 @@ describe('Client side', () => { | |
| </ContextProvider> | ||
| ) | ||
|
|
||
| expect(component.html()).toBe('<div><div>FallBack!</div></div>') | ||
| expect(component.html()).toBe('<div>FallBack!</div>') | ||
| expect(component.html()).toMatchSnapshot() | ||
| turnOnErrors() | ||
| }) | ||
| }) | ||
This file contains hidden or 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 hidden or 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 hidden or 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
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.
Snapshots are a great way to enforce tests without manually writing out all the html in each test!