@@ -12,6 +12,7 @@ beforeAll(() => {
1212} ) ;
1313beforeEach ( ( ) => {
1414 window . Babel = window . Babel || { } ;
15+ window . React = window . React || React ;
1516 renderApp = ( temp , deps , rerender , temp2 ) => {
1617 let secondRender = false ;
1718 const StrintToReactCom = StrintToReact . bind ( undefined , deps ) ;
@@ -44,7 +45,7 @@ describe('rendering : ', () => {
4445 test ( 'generated component from string should be updated when props.children is changed' , ( ) => {
4546 let _ctx , _ctx2 ;
4647 const getCtx = function ( ) {
47- _ctx = new Ctx ( ) ;
48+ _ctx = new Ctx ( React ) ;
4849 _ctx . getComponent = jest . fn ( ( ) => _ctx . _com ) ;
4950 _ctx . _transpile = jest . fn (
5051 ( ) => `() => /*#__PURE__*/React.createElement("p", {
@@ -54,7 +55,7 @@ describe('rendering : ', () => {
5455 return _ctx ;
5556 } ,
5657 getCtx2 = function ( ) {
57- _ctx2 = new Ctx ( ) ;
58+ _ctx2 = new Ctx ( React ) ;
5859 _ctx2 . getComponent = jest . fn ( ( ) => _ctx2 . _com ) ;
5960 _ctx2 . _transpile = jest . fn (
6061 ( ) => `() => /*#__PURE__*/React.createElement("p", {
@@ -73,7 +74,7 @@ describe('rendering : ', () => {
7374 test ( 'it should call updateTemplate method with props.children as a parameter' , ( ) => {
7475 let _ctx ;
7576 const getCtx = function ( ) {
76- _ctx = new Ctx ( ) ;
77+ _ctx = new Ctx ( React ) ;
7778 const updateTemplate = _ctx . updateTemplate ;
7879 _ctx . updateTemplate = jest . fn ( ( temp ) => updateTemplate . call ( _ctx , temp ) ) ;
7980 _ctx . _transpile = jest . fn (
@@ -88,7 +89,10 @@ describe('rendering : ', () => {
8889 } ) ;
8990} ) ;
9091describe ( 'React global variable' , ( ) => {
91- test ( 'this package should set the React global variable' , ( ) => {
92+ test ( 'The constructor should set the React global variable' , ( ) => {
93+ window . React = undefined ;
94+ new Ctx ( React ) ;
9295 expect ( window . React ) . toEqual ( React ) ;
96+ window . React = React ;
9397 } ) ;
9498} ) ;
0 commit comments