@@ -58,11 +58,12 @@ describe('file-attachment', function() {
58
58
} )
59
59
60
60
describe ( 'element' , function ( ) {
61
- let fileAttachment
61
+ let fileAttachment , input
62
62
beforeEach ( function ( ) {
63
- document . body . innerHTML = `<file-attachment></file-attachment>`
63
+ document . body . innerHTML = `<file-attachment><input type="file">< /file-attachment>`
64
64
65
65
fileAttachment = document . querySelector ( 'file-attachment' )
66
+ input = document . querySelector ( 'input' )
66
67
} )
67
68
68
69
afterEach ( function ( ) {
@@ -106,6 +107,20 @@ describe('file-attachment', function() {
106
107
const event = await listener
107
108
assert . equal ( 'test.png' , event . detail . attachments [ 0 ] . file . name )
108
109
} )
110
+
111
+ it ( 'attaches files via input' , async function ( ) {
112
+ const listener = once ( 'file-attachment-accepted' )
113
+
114
+ const dataTransfer = new DataTransfer ( )
115
+ const file = new File ( [ 'hubot' ] , 'test.png' , { type : 'image/png' } )
116
+ dataTransfer . items . add ( file )
117
+ input . files = dataTransfer . files
118
+ input . dispatchEvent ( new Event ( 'change' , { bubbles : true } ) )
119
+
120
+ const event = await listener
121
+ assert . equal ( 'test.png' , event . detail . attachments [ 0 ] . file . name )
122
+ assert . equal ( 0 , input . files . length )
123
+ } )
109
124
} )
110
125
} )
111
126
0 commit comments