This repository was archived by the owner on Mar 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
fix(Provider): should not use felaRenderer explicitly #1842
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8e6084b
initial commit
lucivpav 8a56f10
Merge branch 'master' into fix/provider-renderer
lucivpav ad4d2a5
update changelog
lucivpav c9565c8
Merge branch 'master' into fix/provider-renderer
lucivpav 2decac3
Merge branch 'master' into fix/provider-renderer
lucivpav 862b60e
add tests
lucivpav bfb856a
fix eslint
lucivpav c85037d
Merge branch 'master' into fix/provider-renderer
lucivpav 4ab902e
update changelog
lucivpav bde39ae
simplify using jest.spyOn()
lucivpav ea38a57
use createRenderer() instead of RendererMock
lucivpav f656785
fix changelog
lucivpav 191a3bd
Merge branch 'master' into fix/provider-renderer
lucivpav e2e243a
use dumb fontFaces definition
lucivpav 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,8 @@ import * as React from 'react' | |
|
|
||
| import Provider from 'src/components/Provider/Provider' | ||
| import ProviderConsumer from 'src/components/Provider/ProviderConsumer' | ||
| import { ThemeInput } from 'src/themes/types' | ||
| import { createRenderer } from '@stardust-ui/fela' | ||
|
|
||
| describe('Provider', () => { | ||
| test('is exported', () => { | ||
|
|
@@ -184,4 +186,50 @@ describe('Provider', () => { | |
| }) | ||
| }) | ||
| }) | ||
|
|
||
| describe('calls provided renderer', () => { | ||
| test('calls renderFont', () => { | ||
| const theme: ThemeInput = { | ||
| fontFaces: [ | ||
| { | ||
| name: 'Segoe UI', | ||
| paths: ['public/fonts/segoe-ui-regular.woff2'], | ||
| style: { fontWeight: 400 }, | ||
| }, | ||
| ], | ||
| } | ||
| const renderer = createRenderer() | ||
|
Contributor
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. I cannot use |
||
| const renderFont = jest.spyOn(renderer, 'renderFont') | ||
|
|
||
| mount( | ||
| <Provider theme={theme} renderer={renderer}> | ||
| <div /> | ||
| </Provider>, | ||
| ) | ||
|
|
||
| expect(renderFont).toHaveBeenCalled() | ||
| }) | ||
| }) | ||
|
|
||
| test('calls renderStatic', () => { | ||
| const theme: ThemeInput = { | ||
| staticStyles: [ | ||
| { | ||
| a: { | ||
| textDecoration: 'none', | ||
| }, | ||
| }, | ||
| ], | ||
| } | ||
| const renderer = createRenderer() | ||
| const renderStatic = jest.spyOn(renderer, 'renderStatic') | ||
|
|
||
| mount( | ||
| <Provider theme={theme} renderer={renderer}> | ||
| <div /> | ||
| </Provider>, | ||
| ) | ||
|
|
||
| expect(renderStatic).toHaveBeenCalled() | ||
| }) | ||
| }) | ||
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.
Otherwise we get false positive in
RendererMock.tsx, see typescript-eslint/typescript-eslint#291There 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.
No longer needed at the moment, but I think it will be useful to keep this change, as described in the link above
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.
Yep, let's keep it