Description
I tried writing a test using the most basic SortableTree I could, the example in the docs with a chicken and egg. The test itself looks exactly like this:
import React from 'react'
import renderer from 'react-test-renderer'
import {MySortableTree} from '../components/MySortableTree'
describe('mySortableTree', function () {
it('should render some stuff', function () {
const myTree = renderer.create(
<MySortableTree/>
)
})
})
And I get a TypeError nested deeply in the library which looks like this:
TypeError: this.container.addEventListener is not a function
at ScrollingComponent.componentDidMount (node_modules/react-dnd-
scrollzone/lib/index.js:159:24)
/* lots more lines that are irrelevant */
The above error occurred in the <Scrolling(List)> component:
in Scrolling(List) (created by AutoSizer)
in div (created by AutoSizer)
in AutoSizer (created by ReactSortableTree)
in div (created by ReactSortableTree)
in ReactSortableTree (created by DragDropContext(ReactSortableTree))
in DragDropContext(ReactSortableTree) (at MySortableTree.js:17)
in div (at MySortableTree.js:16)
in MySortableTree (at testMySortableTree.js:8)
Now I'm a complete beginner with writing tests so I could have done something wrong, if you have a better way of mocking it let me know :)
PS: I first tried this with a much more complex SortableTree and got a very similar TypeError:
Cannot read property 'scrollLeft' of null
at Grid.componentDidMount
....
The above error occurred in the <Scrolling(List)> component:
in Scrolling(List) (created by AutoSizer)
in div (created by AutoSizer)
in AutoSizer (created by ReactSortableTree)
in div (created by ReactSortableTree)
....
PPS: Tried doing it with Enzyme.mount instead of renderer.create and got another TypeErrror:
Cannot read property 'getMonitor' of undefined at scrollingComponent.componentDidMount