@@ -42,6 +42,7 @@ describe('clipboard-copy element', function () {
42
42
describe ( 'target element' , function ( ) {
43
43
const nativeClipboard = navigator . clipboard
44
44
let whenCopied
45
+
45
46
beforeEach ( function ( ) {
46
47
const container = document . createElement ( 'div' )
47
48
container . innerHTML = `
@@ -56,16 +57,15 @@ describe('clipboard-copy element', function () {
56
57
copiedText = text
57
58
return Promise . resolve ( )
58
59
} ,
60
+ readText ( ) {
61
+ return Promise . resolve ( copiedText )
62
+ } ,
59
63
} )
60
64
61
65
whenCopied = new Promise ( resolve => {
62
66
document . addEventListener ( 'clipboard-copy' , ( ) => resolve ( copiedText ) , {
63
67
once : true ,
64
68
} )
65
-
66
- document . addEventListener ( 'clipboard-copy-nothing' , ( ) => resolve ( null ) , {
67
- once : true ,
68
- } )
69
69
} )
70
70
} )
71
71
@@ -162,14 +162,21 @@ describe('clipboard-copy element', function () {
162
162
163
163
const button = document . querySelector ( 'clipboard-copy' )
164
164
button . setAttribute ( 'aria-disabled' , 'true' )
165
- let fired = false ;
166
- document . addEventListener ( 'clipboard-copy' , ( ) => { fired = true } , { once : true } )
167
-
165
+
166
+ let fired = false
167
+ document . addEventListener (
168
+ 'clipboard-copy' ,
169
+ ( ) => {
170
+ fired = true
171
+ } ,
172
+ { once : true } ,
173
+ )
174
+
168
175
button . click ( )
169
-
176
+
170
177
await new Promise ( setTimeout )
171
- assert . equal ( fired , false ) ;
172
- assert . equal ( null , text )
178
+ assert . equal ( fired , false )
179
+ assert . equal ( null , await navigator . clipboard . readText ( ) )
173
180
} )
174
181
} )
175
182
0 commit comments