|
|
@@ -6,7 +6,34 @@
|
|
|
import DataTransfer from '../src/datatransfer';
|
|
|
|
|
|
describe( 'DataTransfer', () => {
|
|
|
- describe( 'getData', () => {
|
|
|
+ describe( 'constructor', () => {
|
|
|
+ it( 'should create files from the native files', () => {
|
|
|
+ const dt = new DataTransfer( {
|
|
|
+ files: {
|
|
|
+ 0: 'file1',
|
|
|
+ 1: 'file2',
|
|
|
+ length: 2
|
|
|
+ }
|
|
|
+ } );
|
|
|
+
|
|
|
+ expect( dt.files ).to.deep.equal( [ 'file1', 'file2' ] );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should create files from the native items', () => {
|
|
|
+ const dt = new DataTransfer( {
|
|
|
+ items: {
|
|
|
+ 0: { kind: 'file', getAsFile: () => 'file1' },
|
|
|
+ 1: { kind: 'file', getAsFile: () => 'file2' },
|
|
|
+ 2: { kind: 'someOtherKind' },
|
|
|
+ length: 3
|
|
|
+ },
|
|
|
+ files: []
|
|
|
+ } );
|
|
|
+
|
|
|
+ expect( dt.files ).to.deep.equal( [ 'file1', 'file2' ] );
|
|
|
+ } );
|
|
|
+ } );
|
|
|
+ describe( 'getData()', () => {
|
|
|
it( 'should return data from the native data transfer', () => {
|
|
|
const dt = new DataTransfer( {
|
|
|
getData( type ) {
|
|
|
@@ -18,7 +45,7 @@ describe( 'DataTransfer', () => {
|
|
|
} );
|
|
|
} );
|
|
|
|
|
|
- describe( 'setData', () => {
|
|
|
+ describe( 'setData()', () => {
|
|
|
it( 'should return set data in the native data transfer', () => {
|
|
|
const spy = sinon.spy();
|
|
|
const dt = new DataTransfer( {
|
|
|
@@ -30,4 +57,14 @@ describe( 'DataTransfer', () => {
|
|
|
expect( spy.calledWithExactly( 'text/html', 'bar' ) ).to.be.true;
|
|
|
} );
|
|
|
} );
|
|
|
+
|
|
|
+ describe( 'types', () => {
|
|
|
+ it( 'should return available types', () => {
|
|
|
+ const dt = new DataTransfer( {
|
|
|
+ types: [ 'text/html', 'text/plain' ]
|
|
|
+ } );
|
|
|
+
|
|
|
+ expect( dt.types ).to.deep.equal( [ 'text/html', 'text/plain' ] );
|
|
|
+ } );
|
|
|
+ } );
|
|
|
} );
|