add failing spec

This commit is contained in:
deepak1556 2016-09-10 17:43:27 +05:30
parent 20d5a50ac9
commit d426d4ad90

View file

@ -252,6 +252,9 @@ describe('session module', function () {
var contentDisposition = 'inline; filename="mock.pdf"' var contentDisposition = 'inline; filename="mock.pdf"'
var downloadFilePath = path.join(fixtures, 'mock.pdf') var downloadFilePath = path.join(fixtures, 'mock.pdf')
var downloadServer = http.createServer(function (req, res) { var downloadServer = http.createServer(function (req, res) {
if (req.url === '/?testFilename') {
contentDisposition = 'inline'
}
res.writeHead(200, { res.writeHead(200, {
'Content-Length': mockPDF.length, 'Content-Length': mockPDF.length,
'Content-Type': 'application/pdf', '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 () { 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) { it('does not display a save dialog and reports the done state as interrupted', function (done) {
ipcRenderer.sendSync('set-download-option', false, false) ipcRenderer.sendSync('set-download-option', false, false)