mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-31 19:27:00 -06:00
299e75eca3
* Implemented File Download Experience 1. Initiate download manager when a file download is initiated. 2. Add items to download manager when new items are downloaded. 3. Allow user to open file in default OS app. 4. Allow user to show file in finder/explorer. 5. Allow user to close download bar. * 1. Removed underscore 2. Added safety checks 3. Added support for popouts 4. Creating most elements of download manager if electron * 1. Moved download manager logic to a separate file * 1. Added styles to help pushing up the content of the app when the download manager is being shown. * 1. Added tests for Download Manager. * Removed unnecessary code. * Made adjustments to handle positioning of the download manager through the flexbox model rather than the fixed positioning way. * Removed data attributes being added to body to handle download manager.
95 lines
3.4 KiB
JavaScript
95 lines
3.4 KiB
JavaScript
const downloadManager = require('../js/downloadManager/downloadManager');
|
|
const electron = require('./__mocks__/electron');
|
|
const $ = require('jquery');
|
|
|
|
describe('download manager', function() {
|
|
|
|
describe('Download Manager to create DOM once download is initiated', function () {
|
|
|
|
beforeEach(function () {
|
|
global.document.body.innerHTML =
|
|
'<div id="download-main">' +
|
|
'</div>';
|
|
});
|
|
|
|
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});
|
|
|
|
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 =
|
|
'<div id="download-manager-footer" class="hidden">' +
|
|
'<div id="download-main">' +
|
|
'</div>' +
|
|
'</div>';
|
|
});
|
|
|
|
it('should inject dom element once download is completed', function() {
|
|
|
|
electron.ipcRenderer.send('downloadProgress');
|
|
|
|
expect(document.getElementById('download-manager-footer').classList).not.toContain('hidden');
|
|
|
|
});
|
|
|
|
it('should remove the download bar and clear up the download items', function() {
|
|
|
|
electron.ipcRenderer.send('downloadProgress');
|
|
|
|
console.log(document.getElementById('download-manager-footer').classList);
|
|
expect(document.getElementById('download-manager-footer').classList).not.toContain('hidden');
|
|
|
|
$('#close-download-bar').click();
|
|
expect(document.getElementById('download-manager-footer').classList).toContain('hidden');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
describe('Download Manager to initiate footer', function () {
|
|
|
|
beforeEach(function () {
|
|
global.document.body.innerHTML =
|
|
'<div id="download-manager-footer" class="hidden">' +
|
|
'</div>';
|
|
});
|
|
|
|
it('should inject ul element if not found', function() {
|
|
|
|
electron.ipcRenderer.send('downloadProgress');
|
|
|
|
expect(document.getElementById('download-main')).not.toBeNull();
|
|
expect(document.getElementById('download-manager-footer').classList).not.toContain('hidden');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}); |