add failing spec
authordeepak1556 <hop2deep@gmail.com>
Sat, 10 Sep 2016 12:13:27 +0000 (17:43 +0530)
committerdeepak1556 <hop2deep@gmail.com>
Fri, 16 Sep 2016 10:32:57 +0000 (16:02 +0530)
spec/api-session-spec.js

index 2eb696e..00bc3cf 100644 (file)
@@ -252,6 +252,9 @@ describe('session module', function () {
     var contentDisposition = 'inline; filename="mock.pdf"'
     var downloadFilePath = path.join(fixtures, 'mock.pdf')
     var downloadServer = http.createServer(function (req, res) {
+      if (req.url === '/?testFilename') {
+        contentDisposition = 'inline'
+      }
       res.writeHead(200, {
         'Content-Length': mockPDF.length,
         'Content-Type': 'application/pdf',
@@ -320,6 +323,23 @@ describe('session module', function () {
       })
     })
 
+    it('can generate a default filename', function (done) {
+      downloadServer.listen(0, '127.0.0.1', function () {
+        var port = downloadServer.address().port
+        ipcRenderer.sendSync('set-download-option', true, false)
+        w.loadURL(url + ':' + port + '/?testFilename')
+        ipcRenderer.once('download-done', function (event, state, url, mimeType, receivedBytes, totalBytes, disposition, filename) {
+          assert.equal(state, 'cancelled')
+          assert.equal(filename, 'download.pdf')
+          assert.equal(mimeType, 'application/pdf')
+          assert.equal(receivedBytes, 0)
+          assert.equal(totalBytes, mockPDF.length)
+          assert.equal(disposition, contentDisposition)
+          done()
+        })
+      })
+    })
+
     describe('when a save path is specified and the URL is unavailable', function () {
       it('does not display a save dialog and reports the done state as interrupted', function (done) {
         ipcRenderer.sendSync('set-download-option', false, false)