From 5802cd35915738d17813b0bb44b80eb4988d5289 Mon Sep 17 00:00:00 2001 From: Borewit Date: Sun, 4 Mar 2018 18:44:14 +0100 Subject: [PATCH] #1332: Add unit test for cover selection algorithm. --- test/test-select-poster.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 test/test-select-poster.js diff --git a/test/test-select-poster.js b/test/test-select-poster.js new file mode 100644 index 00000000..a515f5c2 --- /dev/null +++ b/test/test-select-poster.js @@ -0,0 +1,25 @@ +const test = require('tape') + +const fs = require('fs') +const path = require('path') + +const WebTorrent = require('webtorrent') +const torrentPoster = require('../build/renderer/lib/torrent-poster') + +const client = new WebTorrent() + +test("get cover from: 'wiredCd.torrent'", (t) => { + const torrentPath = path.join(__dirname, '..', 'static', 'wiredCd.torrent') + const torrentData = fs.readFileSync(torrentPath) + + client.add(torrentData, (torrent) => { + torrentPoster(torrent, (err, buf, extension) => { + if (err) { + t.fail(err) + } else { + t.equals(extension, '.jpg') + t.end(); + } + }) + }) +})