File tree Expand file tree Collapse file tree 3 files changed +10
-8
lines changed Expand file tree Collapse file tree 3 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ class Ctx {
33 this . _temp = '' ;
44 this . _parentTemp = `"use strict";return @temp;` ;
55 this . _com = null ;
6- if ( ! ( window . hasOwnProperty ( 'Babel' ) && typeof window . Babel === 'object' ) ) {
6+ if ( ! ( Object . prototype . hasOwnProperty . call ( window , 'Babel' ) && typeof window . Babel === 'object' ) ) {
77 throw new Error ( `string-to-react-component package needs @babel/standalone for working correctly.
88 you should load @babel/standalone in the browser.` ) ;
99 }
Original file line number Diff line number Diff line change 11import Ctx from './ctx.js' ;
2- import { TestScheduler } from 'jest' ;
32beforeEach ( ( ) => {
43 window . Babel = { } ;
54} ) ;
@@ -53,19 +52,21 @@ describe('methods : ', () => {
5352 test ( '_validateCodeInsideTheTemp method' , ( ) => {
5453 expect . assertions ( 3 ) ;
5554 const ins = new Ctx ( ) ;
56- try {
55+ {
5756 ins . _com = ( ) => { } ;
5857 ins . _validateCodeInsideTheTemp ( ) ;
5958 expect ( 1 ) . toBe ( 1 ) ;
60- } catch ( er ) { }
61- try {
62- class c { }
59+ }
60+ {
61+ class c {
62+ constructor ( ) { }
63+ }
6364 ins . _com = c ;
6465 ins . _validateCodeInsideTheTemp ( ) ;
6566 expect ( 1 ) . toBe ( 1 ) ;
66- } catch ( er ) { }
67+ }
6768 try {
68- ins . _com = { } ;
69+ ins . _com = '' ;
6970 ins . _validateCodeInsideTheTemp ( ) ;
7071 } catch ( er ) {
7172 expect ( er . message ) . toBe ( 'code inside the passed string into string-to-react-component, should be a function' ) ;
Original file line number Diff line number Diff line change 1+ /* eslint-disable react/prop-types */
12import React , { useRef } from 'react' ;
23window . React = window . React || React ;
34function StringToReactComponent ( { getCtx} , props ) {
You can’t perform that action at this time.
0 commit comments