@@ -17,7 +17,11 @@ describe('Application', () => {
17
17
const application = new Application ( ) ;
18
18
19
19
const oldDocument = global . document ;
20
- global . document = { referrer : 'http://localhost:8080' , createElement : document . createElement . bind ( document ) , body : { addEventListener : ( ) => console . log ( 'mock addEventListener' ) } } ;
20
+ global . document = {
21
+ referrer : 'http://localhost:8080' ,
22
+ createElement : document . createElement . bind ( document ) ,
23
+ addEventListener : ( ) => console . log ( 'mock addEventListener' )
24
+ } ;
21
25
application . init ( { acls, secret, onReady} ) ;
22
26
global . document = oldDocument ;
23
27
@@ -27,7 +31,11 @@ describe('Application', () => {
27
31
28
32
it ( "doesn't set activeACL to document referrer if not in ACL" , ( ) => {
29
33
const insecureApp = new Application ( ) ;
30
- global . document = { referrer : 'http://evilsite.com' , createElement : document . createElement . bind ( document ) , body : { addEventListener : ( ) => console . log ( 'mock addEventListener' ) } } ;
34
+ global . document = {
35
+ referrer : 'http://evilsite.com' ,
36
+ createElement : document . createElement . bind ( document ) ,
37
+ addEventListener : ( ) => console . log ( 'mock addEventListener' )
38
+ } ;
31
39
insecureApp . init ( { acls, secret, onReady} ) ;
32
40
global . document = oldDocument ;
33
41
@@ -49,10 +57,10 @@ describe('Application', () => {
49
57
it ( "sets application's JSONRPC" , ( ) => {
50
58
expect ( application . JSONRPC ) . to . be . an . instanceof ( JSONRPC ) ;
51
59
} ) ;
52
-
60
+
53
61
it ( "calls addEventListener" , sinon . test ( function ( ) {
54
- sinon . spy ( document . body , 'addEventListener' ) ;
55
- expect ( document . body . addEventListener . calledOnce ) ;
62
+ sinon . spy ( document , 'addEventListener' ) ;
63
+ expect ( document . addEventListener . calledOnce ) ;
56
64
} ) ) ;
57
65
58
66
describe ( '#trigger(event, detail)' , ( ) => {
@@ -298,7 +306,7 @@ describe('Application', () => {
298
306
sinon . assert . notCalled ( requestResize ) ;
299
307
} ) ) ;
300
308
} ) ;
301
-
309
+
302
310
describe ( '#requestResize()' , ( ) => {
303
311
it ( "does not resize when resizeConfig is null" , sinon . test ( function ( ) {
304
312
const application = new Application ( ) ;
@@ -339,9 +347,17 @@ describe('Application', () => {
339
347
addEventListener : ( ) => console . log ( 'mock addEventListener' ) ,
340
348
top : { length : - 1 } ,
341
349
} ;
350
+ const oldDocument = global . document ;
351
+ global . document = {
352
+ referrer : 'http://localhost:8080' ,
353
+ createElement : document . createElement . bind ( document ) ,
354
+ addEventListener : ( ) => console . log ( 'mock addEventListener' ) ,
355
+ body : ( function ( ) { return ; } ) ( )
356
+ } ;
342
357
343
358
const application = new Application ( ) ;
344
359
application . init ( { acls : [ 'http://localhost:8080' ] } ) ;
360
+ global . document = oldDocument ;
345
361
sinon . spy ( window , 'addEventListener' ) ;
346
362
347
363
application . launch ( ) ;
0 commit comments