From baed9c5ba70db2d37ba9d326c885c2082633a9f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jimmy=20W=C3=A4rting?= Date: Fri, 24 Aug 2018 13:50:22 +0200 Subject: Added test for file.downloaded --- test/node/basic.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/node/basic.js b/test/node/basic.js index 7559309..f01aeef 100644 --- a/test/node/basic.js +++ b/test/node/basic.js @@ -112,7 +112,7 @@ test('client.seed: filesystem path to folder with one file, string', function (t }) test('client.seed: filesystem path to folder with multiple files, string', function (t) { - t.plan(6) + t.plan(7) var client = new WebTorrent({ dht: false, tracker: false }) @@ -124,6 +124,17 @@ test('client.seed: filesystem path to folder with multiple files, string', funct t.equal(torrent.infoHash, fixtures.numbers.parsedTorrent.infoHash) t.equal(torrent.magnetURI, fixtures.numbers.magnetURI) + const downloaded = torrent.files.map(file => ({ + length: file.length, + downloaded: file.downloaded + })) + + t.deepEqual(downloaded, [ + { length: 1, downloaded: 1 }, + { length: 2, downloaded: 2 }, + { length: 3, downloaded: 3 } + ], 'expected downloaded to be calculated correctly') + client.remove(torrent, function (err) { t.error(err, 'torrent destroyed') }) t.equal(client.torrents.length, 0) -- cgit v1.2.3