From 2b77c4e6421f9b051c40eb6faafe3654bb62f27a Mon Sep 17 00:00:00 2001 From: Symphony Date: Sun, 2 Jul 2017 18:23:34 +0530 Subject: [PATCH] 1. Fixed download manager test issues. 2. Removed usage of jQuery for tests. --- js/windowMgr.js | 2 +- tests/DownloadManager.test.js | 56 ++++++++++++++--------------------- 2 files changed, 24 insertions(+), 34 deletions(-) diff --git a/js/windowMgr.js b/js/windowMgr.js index 5c938cd2..decba734 100644 --- a/js/windowMgr.js +++ b/js/windowMgr.js @@ -195,7 +195,7 @@ function doCreateMainWindow(initialUrl, initialBounds) { webContents.send('downloadProgress'); // Send file path when download is complete - item.once('done', (event, state) => { + item.once('done', (e, state) => { if (state === 'completed') { let data = { _id: getGuid(), diff --git a/tests/DownloadManager.test.js b/tests/DownloadManager.test.js index c8120193..20e8b7f5 100644 --- a/tests/DownloadManager.test.js +++ b/tests/DownloadManager.test.js @@ -1,73 +1,59 @@ const downloadManager = require('../js/downloadManager/downloadManager'); const electron = require('./__mocks__/electron'); -const $ = require('jquery'); - -describe('download manager', function() { +describe('download manager', function () { describe('Download Manager to create DOM once download is initiated', function () { - beforeEach(function () { global.document.body.innerHTML = '
' + '
'; }); - it('should inject download bar element into DOM once download is initiated', function() { - - electron.ipcRenderer.send('downloadCompleted', {_id: '12345', fileName: 'test', total: 100}); - + it('should inject download bar element into DOM once download is initiated', function () { + electron.ipcRenderer.send('downloadCompleted', { _id: '12345', fileName: 'test', total: 100 }); expect(document.getElementsByClassName('text-cutoff')[0].innerHTML).toBe('test'); expect(document.getElementById('per').innerHTML).toBe('100 Downloaded'); - }); - it('should inject multiple download items during multiple downloads', function() { - - electron.ipcRenderer.send('downloadCompleted', {_id: '12345', fileName: 'test', total: 100}); - electron.ipcRenderer.send('downloadCompleted', {_id: '67890', fileName: 'test1', total: 200}); + it('should inject multiple download items during multiple downloads', function () { + electron.ipcRenderer.send('downloadCompleted', { _id: '12345', fileName: 'test', total: 100 }); + electron.ipcRenderer.send('downloadCompleted', { _id: '67890', fileName: 'test1', total: 200 }); let fileNames = document.getElementsByClassName('text-cutoff'); - expect(fileNames[0].innerHTML).toBe('test1'); expect(fileNames[1].innerHTML).toBe('test'); expect(document.getElementById('per').innerHTML).toBe('100 Downloaded'); let downloadElements = document.getElementsByClassName('download-element'); - expect(downloadElements[0].id).toBe('67890'); expect(downloadElements[1].id).toBe('12345'); - }); }); describe('Download Manager to initiate footer', function () { - beforeEach(function () { global.document.body.innerHTML = - '