2017-10-21 105 views
0

我測試飾JSCC與酶和玩笑的成分,但我收到以下錯誤:酶的裝飾組件類型錯誤:無法讀取屬性「contextTypes」的未定義

TypeError: Cannot read property 'contextTypes' of undefined

如何測試這種風格的組成部分?

import React from 'react' 
 
import { shallow } from 'enzyme' 
 
import { PdfViewer } from './PdfViewer' 
 

 
const baseProps = { 
 
    location: 'url', 
 
    defaultPage: 1, 
 
    classes: {}, 
 
    handlePageChanged:() => {}, 
 
} 
 

 
describe('<PdfViewer />',() => { 
 
    it('should work',() => { 
 
    const wrapper = shallow(<PdfViewer {...baseProps} />) 
 
    console.log(wrapper.debug()) 
 
    }) 
 
})

組件被裝飾爲:

​​

回答

0

import { muiTheme } from 'material-ui/styles' 
 
const wrapper = shallow(<PdfViewer {...baseProps} />, { context: { muiTheme } })

相關問題