all files / src/events/__tests__/ createOnDrop.spec.js

100% Statements 16/16
100% Branches 4/4
100% Functions 4/4
100% Lines 13/13
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27                              
import expect, {createSpy} from 'expect';
import createOnDrop from '../createOnDrop';
import {dataKey} from '../createOnDragStart';
 
describe('createOnDrop', () => {
  it('should return a function', () => {
    expect(createOnDrop())
      .toExist()
      .toBeA('function');
  });
 
  it('should return a function that calls change with result from getData', () => {
    const change = createSpy();
    const getData = createSpy().andReturn('bar');
    createOnDrop('foo', change)({
      dataTransfer: {getData}
    });
    expect(getData)
      .toHaveBeenCalled()
      .toHaveBeenCalledWith(dataKey);
    expect(change)
      .toHaveBeenCalled()
      .toHaveBeenCalledWith('foo', 'bar');
  });
 
});