-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EDD-19: As a download app user, I want to be able to clear my downloa…
…d history. (#28) * EDD-19: Adds clearing download history on the downloadHistory page for the header button and individual actions
- Loading branch information
1 parent
ba9da56
commit 72cb052
Showing
14 changed files
with
302 additions
and
15 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/eventHandlers/__tests__/clearDownloadHistory.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import clearDownloadHistory from '../clearDownloadHistory' | ||
|
||
describe('clearDownloadHistory', () => { | ||
describe('when a downloadId is not passed in', () => { | ||
test('ensure that downloads, files, and pauses which are not active are deleted', async () => { | ||
const info = {} | ||
const database = { | ||
clearDownloadHistoryDownloads: jest.fn() | ||
} | ||
|
||
await clearDownloadHistory({ | ||
database, | ||
info | ||
}) | ||
|
||
expect(database.clearDownloadHistoryDownloads).toHaveBeenCalledTimes(1) | ||
|
||
expect(database.clearDownloadHistoryDownloads).toHaveBeenCalledWith(undefined) | ||
}) | ||
}) | ||
|
||
describe('when a downloadId is passed in', () => { | ||
test('ensure only the downloads, files, and pauses associated to the downloadId are deleted', async () => { | ||
const info = { | ||
downloadId: 'mock-download-id' | ||
} | ||
const database = { | ||
clearDownloadHistoryDownloads: jest.fn() | ||
} | ||
|
||
await clearDownloadHistory({ | ||
database, | ||
info | ||
}) | ||
|
||
expect(database.clearDownloadHistoryDownloads).toHaveBeenCalledTimes(1) | ||
expect(database.clearDownloadHistoryDownloads).toHaveBeenCalledWith('mock-download-id') | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// @ts-nocheck | ||
|
||
/** | ||
* Removes downloads in the download history from the database | ||
* @param {Object} params | ||
* @param {Object} params.database `EddDatabase` instance | ||
* @param {Object} params.info `info` parameter from ipc message | ||
*/ | ||
const clearDownloadHistory = async ({ | ||
database, | ||
info | ||
}) => { | ||
const { downloadId } = info | ||
|
||
// Clear the download(s) in the history | ||
await database.clearDownloadHistoryDownloads(downloadId) | ||
} | ||
|
||
export default clearDownloadHistory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.