@@ -12,6 +12,7 @@ beforeAll(() => {
12
12
} ) ;
13
13
beforeEach ( ( ) => {
14
14
window . Babel = window . Babel || { } ;
15
+ window . React = window . React || React ;
15
16
renderApp = ( temp , deps , rerender , temp2 ) => {
16
17
let secondRender = false ;
17
18
const StrintToReactCom = StrintToReact . bind ( undefined , deps ) ;
@@ -44,7 +45,7 @@ describe('rendering : ', () => {
44
45
test ( 'generated component from string should be updated when props.children is changed' , ( ) => {
45
46
let _ctx , _ctx2 ;
46
47
const getCtx = function ( ) {
47
- _ctx = new Ctx ( ) ;
48
+ _ctx = new Ctx ( React ) ;
48
49
_ctx . getComponent = jest . fn ( ( ) => _ctx . _com ) ;
49
50
_ctx . _transpile = jest . fn (
50
51
( ) => `() => /*#__PURE__*/React.createElement("p", {
@@ -54,7 +55,7 @@ describe('rendering : ', () => {
54
55
return _ctx ;
55
56
} ,
56
57
getCtx2 = function ( ) {
57
- _ctx2 = new Ctx ( ) ;
58
+ _ctx2 = new Ctx ( React ) ;
58
59
_ctx2 . getComponent = jest . fn ( ( ) => _ctx2 . _com ) ;
59
60
_ctx2 . _transpile = jest . fn (
60
61
( ) => `() => /*#__PURE__*/React.createElement("p", {
@@ -73,7 +74,7 @@ describe('rendering : ', () => {
73
74
test ( 'it should call updateTemplate method with props.children as a parameter' , ( ) => {
74
75
let _ctx ;
75
76
const getCtx = function ( ) {
76
- _ctx = new Ctx ( ) ;
77
+ _ctx = new Ctx ( React ) ;
77
78
const updateTemplate = _ctx . updateTemplate ;
78
79
_ctx . updateTemplate = jest . fn ( ( temp ) => updateTemplate . call ( _ctx , temp ) ) ;
79
80
_ctx . _transpile = jest . fn (
@@ -88,7 +89,10 @@ describe('rendering : ', () => {
88
89
} ) ;
89
90
} ) ;
90
91
describe ( '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 ) ;
92
95
expect ( window . React ) . toEqual ( React ) ;
96
+ window . React = React ;
93
97
} ) ;
94
98
} ) ;
0 commit comments