-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
1,219 additions
and
837 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
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,66 @@ | ||
import test from 'ava'; | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { Provider } from '..'; | ||
import jpex, { Jpex } from 'jpex'; | ||
|
||
test('calls onMount on mount', (t) => { | ||
let called = false; | ||
const callback = () => { | ||
called = true; | ||
}; | ||
|
||
render( | ||
<Provider onMount={callback}> | ||
<div/> | ||
</Provider> | ||
); | ||
|
||
t.true(called); | ||
}); | ||
|
||
test('passes the current jpex instance', (t) => { | ||
const newJpex = jpex.extend(); | ||
let ioc: Jpex; | ||
const callback = (jpex: Jpex) => { | ||
ioc = jpex; | ||
}; | ||
|
||
render( | ||
<Provider | ||
value={newJpex} | ||
onMount={callback} | ||
> | ||
<div/> | ||
</Provider> | ||
); | ||
|
||
t.is(ioc, newJpex); | ||
}); | ||
|
||
test('does not call on subsequent renders', (t) => { | ||
let callCount = 0; | ||
const callback = () => { | ||
callCount = callCount + 1; | ||
}; | ||
|
||
const Inner = () => { | ||
return (<div/>); | ||
}; | ||
|
||
const { rerender } = render( | ||
<Provider onMount={callback}> | ||
<Inner/> | ||
</Provider> | ||
); | ||
|
||
t.is(callCount, 1); | ||
|
||
rerender( | ||
<Provider onMount={callback}> | ||
<Inner/> | ||
</Provider> | ||
); | ||
|
||
t.is(callCount, 1); | ||
}); |
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
Oops, something went wrong.