From 7277ffba8f5389afafd3bd04306f137fe51fad05 Mon Sep 17 00:00:00 2001 From: Alexey Kasyanchuk Date: Sun, 2 Dec 2018 21:13:25 +0300 Subject: [PATCH] test(downloading): add downloading test --- package-lock.json | 6 ++++ package.json | 1 + src/app/context-menu.js | 2 +- src/app/download-torrent-menu.js | 4 ++- src/app/torrent.js | 8 ++--- tests/download.test.js | 53 ++++++++++++++++++++++++++++++++ 6 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 tests/download.test.js diff --git a/package-lock.json b/package-lock.json index 5f522e5..a544085 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12507,6 +12507,12 @@ "integrity": "sha1-3oGf282E3M2PrlnGrreWFbnSZqw=", "dev": true }, + "md5-file": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/md5-file/-/md5-file-4.0.0.tgz", + "integrity": "sha512-UC0qFwyAjn4YdPpKaDNw6gNxRf7Mcx7jC1UGCY4boCzgvU2Aoc1mOGzTtrjjLKhM5ivsnhoKpQVxKPp+1j1qwg==", + "dev": true + }, "md5.js": { "version": "1.3.4", "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.4.tgz", diff --git a/package.json b/package.json index cfda472..907ea73 100644 --- a/package.json +++ b/package.json @@ -168,6 +168,7 @@ "express": "^4.16.3", "friendly-errors-webpack-plugin": "^1.6.1", "html-webpack-plugin": "^3.2.0", + "md5-file": "^4.0.0", "mocha": "^5.2.0", "socket.io": "^2.1.0", "source-map-support": "^0.5.0", diff --git a/src/app/context-menu.js b/src/app/context-menu.js index 7599c16..682b122 100644 --- a/src/app/context-menu.js +++ b/src/app/context-menu.js @@ -40,7 +40,7 @@ export default class ContextMenu extends Component { zIndex: 3 }, !this.props.rightAlign ? { left: -30 } : { right: -30 })}> { - this.props.menu && this.props.menu.map((menu, index) => { + this.props.menu && this.props.menu.map((menu, index) => { menu.click() this.setState({toggle: !this.state.toggle}) e.preventDefault() diff --git a/src/app/download-torrent-menu.js b/src/app/download-torrent-menu.js index bc9fafe..a621a12 100644 --- a/src/app/download-torrent-menu.js +++ b/src/app/download-torrent-menu.js @@ -16,7 +16,9 @@ export default (props) => { if(props.onAdded) props.onAdded(added) }) - }, icon: diff --git a/src/app/torrent.js b/src/app/torrent.js index 24c08d2..3ac8f44 100644 --- a/src/app/torrent.js +++ b/src/app/torrent.js @@ -371,7 +371,7 @@ export default class Torrent extends Component { mode="determinate" value={this.state.downloadProgress && (this.state.downloadProgress.progress ? this.state.downloadProgress.progress : 0) * 100} /> -
{this.state.downloadProgress && (this.state.downloadProgress.progress * 100).toFixed(1)}%
+
{this.state.downloadProgress && (this.state.downloadProgress.progress * 100).toFixed(1)}%
{ this.state.downloadProgress.progress !== 1 && @@ -463,7 +463,7 @@ export default class Torrent extends Component { this.setState({startingDownloading: true}) }}> - + - + - + { + return (await app.client.getText('.torrentRow .progressDownloading')) === '100.0%' + }, 60000, 'expected that download will be finished', 200) + }) + + it("check file after download", async function() { + this.timeout(10000); + const file = config.client.downloadPath + "/Roblox_setup.exe" + assert(fs.existsSync(file)); + assert.equal(await md5(file), '7df171da63e2013c9b17e1857615b192'); + }) + + it("delete download from manager (after finish)", async function() { + this.timeout(10000); + const { app } = this + await app.client.waitForExist('.torrentRow .deleteDownloadAfterFinish') + await app.client.click('.torrentRow .deleteDownloadAfterFinish') + }) + + it("file must still exists after delete from manager", async function() { + this.timeout(10000); + const file = config.client.downloadPath + "/Roblox_setup.exe" + assert(fs.existsSync(file)); + assert.equal(await md5(file), '7df171da63e2013c9b17e1857615b192'); + }) +});