Skip to content

Commit

Permalink
Fix test timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
nadbm committed Jun 6, 2018
1 parent 6a6fc71 commit aa73eea
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions test/Datasheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -1687,44 +1687,41 @@ describe('Component', () => {
}, 1)
})

it('should be called once when pasting', (done) => {
wrapper.find('td').at(0).simulate('mouseDown')
it('should be called with two arguments if pasted data exceeds bounds', (done) => {
wrapper.find('td').at(3).simulate('mouseDown')
let evt = document.createEvent('HTMLEvents')
evt.initEvent('paste', false, true)
evt.clipboardData = { getData: (type) => '99\t100\n1001\t1002'}
document.dispatchEvent(evt)

expect(handlePaste.called).toBe(false)
setTimeout(() => {
expect(handlePaste.called).toBe(false)
expect(handleCellsChanged.calledOnce).toBe(true)

expect(handleCellsChanged.firstCall.calledWith([
{cell: data[0][0], row: 0, col: 0, value: '99'},
{cell: data[0][1], row: 0, col: 1, value: '100'},
{cell: data[1][0], row: 1, col: 0, value: '1001'},
{cell: data[1][1], row: 1, col: 1, value: '1002'}
{cell: data[1][1], row: 1, col: 1, value: '99'}
], [
{row: 1, col: 2, value: '100'},
{row: 2, col: 1, value: '1001'},
{row: 2, col: 2, value: '1002'}
])).toBe(true)
expect(handleChange.called).toBe(false)
done()
}, 200)
}, 100)
})

it('should be called with two arguments if pasted data exceeds bounds', (done) => {
wrapper.find('td').at(3).simulate('mouseDown')
it('should be called once when pasting', (done) => {
wrapper.find('td').at(0).simulate('mouseDown')
let evt = document.createEvent('HTMLEvents')
evt.initEvent('paste', false, true)
evt.clipboardData = { getData: (type) => '99\t100\n1001\t1002'}
document.dispatchEvent(evt)
expect(handlePaste.called).toBe(false)

setTimeout(() => {
expect(handleCellsChanged.calledOnce).toBe(true)
expect(handleCellsChanged.firstCall.calledWith([
{cell: data[1][1], row: 1, col: 1, value: '99'}
], [
{row: 1, col: 2, value: '100'},
{row: 2, col: 1, value: '1001'},
{row: 2, col: 2, value: '1002'}
{cell: data[0][0], row: 0, col: 0, value: '99'},
{cell: data[0][1], row: 0, col: 1, value: '100'},
{cell: data[1][0], row: 1, col: 0, value: '1001'},
{cell: data[1][1], row: 1, col: 1, value: '1002'}
])).toBe(true)
expect(handleChange.called).toBe(false)
done()
Expand Down

0 comments on commit aa73eea

Please sign in to comment.