@@ -39,6 +39,21 @@ describe('new CspDirectives()',() => {
39
39
'Referrer-Policy' : 'strict-origin-when-cross-origin' ,
40
40
} ) ;
41
41
} ) ;
42
+ it ( 'returns boolean directives' , ( ) => {
43
+ const csp : Directives = {
44
+ 'upgrade-insecure-requests' : true ,
45
+ } ;
46
+ const inst = new CspDirectives ( csp , [ ] , csp ) ;
47
+ const getHeaders = jest . spyOn ( inst , 'getHeaders' ) ;
48
+ const headers = inst . getHeaders ( ) ;
49
+ expect ( getHeaders ) . toHaveReturned ( ) ;
50
+ expect ( headers ) . toMatchObject ( {
51
+ 'Content-Security-Policy-Report-Only' : 'upgrade-insecure-requests;' ,
52
+ 'Content-Security-Policy' : 'upgrade-insecure-requests;' ,
53
+ 'Report-To' : '' ,
54
+ 'Referrer-Policy' : 'strict-origin-when-cross-origin' ,
55
+ } ) ;
56
+ } ) ;
42
57
it ( 'returns on all set' , ( ) => {
43
58
const sampleSha256 = `sha256-${ sample64Hash ( 'sha256' ) } ` as const ;
44
59
const csp : Directives = {
@@ -73,7 +88,7 @@ describe('new CspDirectives()',() => {
73
88
endpoints : [ { url :endpoint } ] ,
74
89
} ,
75
90
] ;
76
- const result = Object . entries ( csp ) . map ( ( [ k , v ] ) => ` ${ k } '${ v } ';` ) . join ( '' ) ;
91
+ const result = Object . entries ( csp ) . map ( ( [ k , v ] ) => `${ k } '${ v } ';` ) . join ( ' ' ) ;
77
92
const inst = new CspDirectives ( csp , reportTo , csp , 'strict-origin' ) ;
78
93
const getHeaders = jest . spyOn ( inst , 'getHeaders' ) ;
79
94
const headers = inst . getHeaders ( ) ;
0 commit comments