@@ -1350,27 +1350,63 @@ describe('File', function() {
13501350 } ) ;
13511351 } ) ;
13521352
1353- it ( 'should add response content disposition parameter' , function ( done ) {
1354- var disposition = 'attachment; filename="fname.ext" ' ;
1353+ it ( 'should add response- content-type parameter' , function ( done ) {
1354+ var type = 'application/json ' ;
13551355 directoryFile . getSignedUrl ( {
13561356 action : 'read' ,
13571357 expires : Math . round ( Date . now ( ) / 1000 ) + 5 ,
1358- responseDisposition : disposition
1358+ responseType : type
13591359 } , function ( err , signedUrl ) {
1360- assert ( signedUrl . indexOf ( encodeURIComponent ( disposition ) ) > - 1 ) ;
1360+ assert ( signedUrl . indexOf ( encodeURIComponent ( type ) ) > - 1 ) ;
13611361 done ( ) ;
13621362 } ) ;
13631363 } ) ;
13641364
1365- it ( 'should add response content type parameter' , function ( done ) {
1366- var type = 'application/json' ;
1367- directoryFile . getSignedUrl ( {
1368- action : 'read' ,
1369- expires : Math . round ( Date . now ( ) / 1000 ) + 5 ,
1370- responseType : type
1371- } , function ( err , signedUrl ) {
1372- assert ( signedUrl . indexOf ( encodeURIComponent ( type ) ) > - 1 ) ;
1373- done ( ) ;
1365+ describe ( 'promptSaveAs' , function ( ) {
1366+ it ( 'should add response-content-disposition' , function ( done ) {
1367+ var disposition = 'attachment; filename="fname.ext"' ;
1368+ directoryFile . getSignedUrl ( {
1369+ action : 'read' ,
1370+ expires : Math . round ( Date . now ( ) / 1000 ) + 5 ,
1371+ promptSaveAs : 'fname.ext'
1372+ } , function ( err , signedUrl ) {
1373+ assert ( signedUrl . indexOf ( disposition ) > - 1 ) ;
1374+ done ( ) ;
1375+ } ) ;
1376+ } ) ;
1377+ } ) ;
1378+
1379+ describe ( 'responseDisposition' , function ( ) {
1380+ it ( 'should add response-content-disposition' , function ( done ) {
1381+ var disposition = 'attachment; filename="fname.ext"' ;
1382+ directoryFile . getSignedUrl ( {
1383+ action : 'read' ,
1384+ expires : Math . round ( Date . now ( ) / 1000 ) + 5 ,
1385+ responseDisposition : disposition
1386+ } , function ( err , signedUrl ) {
1387+ assert ( signedUrl . indexOf ( encodeURIComponent ( disposition ) ) > - 1 ) ;
1388+ done ( ) ;
1389+ } ) ;
1390+ } ) ;
1391+
1392+ it ( 'should warn and ignore promptSaveAs if set' , function ( done ) {
1393+ var disposition = 'attachment; filename="fname.ext"' ;
1394+ var saveAs = 'fname2.ext' ;
1395+ var oldWarn = console . warn ;
1396+ console . warn = function ( message ) {
1397+ assert ( message . indexOf ( 'promptSaveAs' ) > - 1 ) ;
1398+ console . warn = oldWarn ;
1399+ } ;
1400+ directoryFile . getSignedUrl ( {
1401+ action : 'read' ,
1402+ expires : Math . round ( Date . now ( ) / 1000 ) + 5 ,
1403+ promptSaveAs : saveAs ,
1404+ responseDisposition : 'attachment; filename="fname.ext"'
1405+ } , function ( err , signedUrl ) {
1406+ assert ( signedUrl . indexOf ( encodeURIComponent ( disposition ) ) > - 1 ) ;
1407+ assert ( signedUrl . indexOf ( encodeURIComponent ( saveAs ) ) === - 1 ) ;
1408+ done ( ) ;
1409+ } ) ;
13741410 } ) ;
13751411 } ) ;
13761412
0 commit comments