-
-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: π fix tests after context refactor and Enzyme update
BREAKING CHANGE: moved to React 16 context API
- Loading branch information
Showing
13 changed files
with
87 additions
and
163 deletions.
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 |
---|---|---|
|
@@ -12,3 +12,4 @@ yarn.lock | |
/dist_docs/ | ||
_book/ | ||
/storybook-static/ | ||
yarn-error.log |
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 |
---|---|---|
|
@@ -21,3 +21,4 @@ _book/ | |
/.storybook/ | ||
/docs/ | ||
/storybook-static/ | ||
yarn-error.log |
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* @jest-environment node | ||
*/ | ||
|
||
import {createElement as h} from 'react'; | ||
import {renderToStaticMarkup} from 'react-dom/server'; | ||
import {Provider, Consumer} from '..'; | ||
|
||
describe('<BatterySensor> SSR', () => { | ||
it('renders without crashing with no value', () => { | ||
const element = ( | ||
<Provider name="theme" value={{color: 'red'}}> | ||
<Consumer name="theme">{(theme) => { | ||
return <div>Color is: {theme.color}</div>; | ||
}}</Consumer> | ||
</Provider> | ||
); | ||
const html = renderToStaticMarkup(element); | ||
|
||
expect(html).toBe('<div>Color is: red</div>'); | ||
}); | ||
|
||
it('<Provider/> passes context to <Consumer/>', () => { | ||
const value = {foo: 'bar'}; | ||
const jsx = h( | ||
Provider, | ||
{name: 'a', value}, | ||
h(Consumer, {name: 'a'}, val => { | ||
return h('div', {}, val.foo); | ||
}) | ||
); | ||
const html = renderToStaticMarkup(jsx); | ||
|
||
expect(html).toBe('<div>bar</div>'); | ||
}); | ||
|
||
it('multiple <Provider/> contexts received by multiple <Consumer/>s', () => { | ||
const jsx = h( | ||
Provider, | ||
{name: 'a', value: {foo1: 'bar'}}, | ||
h( | ||
Provider, | ||
{name: 'b', value: {foo2: 'bar2'}}, | ||
h(Consumer, {name: 'b'}, val1 => { | ||
return h(Consumer, {name: 'a'}, val2 => { | ||
return h('div', {}, val1.foo2 + val2.foo1); | ||
}); | ||
}) | ||
) | ||
); | ||
|
||
const html = renderToStaticMarkup(jsx); | ||
|
||
expect(html).toBe('<div>bar2bar</div>'); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,5 +1,5 @@ | ||
/** | ||
* @jest-environment jsdom | ||
* @jest-environment node | ||
*/ | ||
|
||
import {createElement as h} from 'react'; | ||
|
This file was deleted.
Oops, something went wrong.
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