datatransfer.js 789 B

123456789101112131415161718192021222324252627282930313233
  1. /**
  2. * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. import DataTransfer from '../src/datatransfer';
  6. describe( 'DataTransfer', () => {
  7. describe( 'getData', () => {
  8. it( 'should return data from the native data transfer', () => {
  9. const dt = new DataTransfer( {
  10. getData( type ) {
  11. return 'foo:' + type;
  12. }
  13. } );
  14. expect( dt.getData( 'x/y' ) ).to.equal( 'foo:x/y' );
  15. } );
  16. } );
  17. describe( 'setData', () => {
  18. it( 'should return set data in the native data transfer', () => {
  19. const spy = sinon.spy();
  20. const dt = new DataTransfer( {
  21. setData: spy
  22. } );
  23. dt.setData( 'text/html', 'bar' );
  24. expect( spy.calledWithExactly( 'text/html', 'bar' ) ).to.be.true;
  25. } );
  26. } );
  27. } );