From f592a55e21b916fce043b5524297e7c70ffff738 Mon Sep 17 00:00:00 2001 From: Kylart Date: Wed, 15 Apr 2020 02:05:17 +0200 Subject: [PATCH] Added tests for bindings --- test/bindings/index.js | 2 + test/bindings/nameParser/data.json | 236 +++++++++++++++++++++++++ test/bindings/nameParser/index.spec.js | 33 ++++ test/bindings/torrent/index.spec.js | 26 +++ test/index.spec.js | 4 + 5 files changed, 301 insertions(+) create mode 100644 test/bindings/index.js create mode 100644 test/bindings/nameParser/data.json create mode 100644 test/bindings/nameParser/index.spec.js create mode 100644 test/bindings/torrent/index.spec.js diff --git a/test/bindings/index.js b/test/bindings/index.js new file mode 100644 index 0000000..1b11ad6 --- /dev/null +++ b/test/bindings/index.js @@ -0,0 +1,2 @@ +require('./nameParser/index.spec')() +require('./torrent/index.spec')() diff --git a/test/bindings/nameParser/data.json b/test/bindings/nameParser/data.json new file mode 100644 index 0000000..442433f --- /dev/null +++ b/test/bindings/nameParser/data.json @@ -0,0 +1,236 @@ +[ + { + "filename": "[HorribleSubs] Sakura Trick - 12[1080p].mkv", + "result": { + "anime_title": "Sakura Trick", + "episode_number": "12", + "file_extension": "mkv", + "file_name": "[HorribleSubs] Sakura Trick - 12[1080p]", + "release_group": "HorribleSubs", + "video_resolution": "1080p" + } + }, + { + "filename": "[HorribleSubs] Sakura Trick - 12[720p].mkv", + "result": { + "anime_title": "Sakura Trick", + "episode_number": "12", + "file_extension": "mkv", + "file_name": "[HorribleSubs] Sakura Trick - 12[720p]", + "release_group": "HorribleSubs", + "video_resolution": "720p" + } + }, + { + "filename": "[HorribleSubs] Sakura Trick - 12[480p].mkv", + "result": { + "anime_title": "Sakura Trick", + "episode_number": "12", + "file_extension": "mkv", + "file_name": "[HorribleSubs] Sakura Trick - 12[480p]", + "release_group": "HorribleSubs", + "video_resolution": "480p" + } + }, + { + "filename": "[HorribleSubs] Sakura Trick - 11[1080p].mkv", + "result": { + "anime_title": "Sakura Trick", + "episode_number": "11", + "file_extension": "mkv", + "file_name": "[HorribleSubs] Sakura Trick - 11[1080p]", + "release_group": "HorribleSubs", + "video_resolution": "1080p" + } + }, + { + "filename": "[HorribleSubs] Sakura Trick - 11[720p].mkv", + "result": { + "anime_title": "Sakura Trick", + "episode_number": "11", + "file_extension": "mkv", + "file_name": "[HorribleSubs] Sakura Trick - 11[720p]", + "release_group": "HorribleSubs", + "video_resolution": "720p" + } + }, + { + "filename": "[HorribleSubs] Sakura Trick - 11[480p].mkv", + "result": { + "anime_title": "Sakura Trick", + "episode_number": "11", + "file_extension": "mkv", + "file_name": "[HorribleSubs] Sakura Trick - 11[480p]", + "release_group": "HorribleSubs", + "video_resolution": "480p" + } + }, + { + "filename": "[HorribleSubs] Houkago Teibou Nisshi - 02[1080p].mkv", + "result": { + "anime_title": "Houkago Teibou Nisshi", + "episode_number": "02", + "file_extension": "mkv", + "file_name": "[HorribleSubs] Houkago Teibou Nisshi - 02[1080p]", + "release_group": "HorribleSubs", + "video_resolution": "1080p" + } + }, + { + "filename": "[HorribleSubs] Houkago Teibou Nisshi - 02[720p].mkv", + "result": { + "anime_title": "Houkago Teibou Nisshi", + "episode_number": "02", + "file_extension": "mkv", + "file_name": "[HorribleSubs] Houkago Teibou Nisshi - 02[720p]", + "release_group": "HorribleSubs", + "video_resolution": "720p" + } + }, + { + "filename": "[HorribleSubs] Houkago Teibou Nisshi - 02[360p].mkv", + "result": { + "anime_title": "Houkago Teibou Nisshi", + "episode_number": "02", + "file_extension": "mkv", + "file_name": "[HorribleSubs] Houkago Teibou Nisshi - 02[360p]", + "release_group": "HorribleSubs", + "video_resolution": "360p" + } + }, + { + "filename": "[HorribleSubs] Black Clover - 130[1080p].mkv", + "result": { + "anime_title": "Black Clover", + "episode_number": "130", + "file_extension": "mkv", + "file_name": "[HorribleSubs] Black Clover - 130[1080p]", + "release_group": "HorribleSubs", + "video_resolution": "1080p" + } + }, + { + "filename": "[HorribleSubs] Black Clover - 130[720p].mkv", + "result": { + "anime_title": "Black Clover", + "episode_number": "130", + "file_extension": "mkv", + "file_name": "[HorribleSubs] Black Clover - 130[720p]", + "release_group": "HorribleSubs", + "video_resolution": "720p" + } + }, + { + "filename": "[HorribleSubs] Black Clover - 130[480p].mkv", + "result": { + "anime_title": "Black Clover", + "episode_number": "130", + "file_extension": "mkv", + "file_name": "[HorribleSubs] Black Clover - 130[480p]", + "release_group": "HorribleSubs", + "video_resolution": "480p" + } + }, + { + "filename": "[Erai-raws] Shadowverse - 02[1080p][Multiple Subtitle].mkv", + "result": { + "anime_title": "Shadowverse", + "episode_number": "02", + "file_extension": "mkv", + "file_name": "[Erai-raws] Shadowverse - 02[1080p][Multiple Subtitle]", + "release_group": "Erai-raws", + "video_resolution": "1080p" + } + }, + { + "filename": "[Erai-raws] Shadowverse - 02[720p][Multiple Subtitle].mkv", + "result": { + "anime_title": "Shadowverse", + "episode_number": "02", + "file_extension": "mkv", + "file_name": "[Erai-raws] Shadowverse - 02[720p][Multiple Subtitle]", + "release_group": "Erai-raws", + "video_resolution": "720p" + } + }, + { + "filename": "[Erai-raws] Princess Connect! Re - Dive - 02[1080p][Multiple Subtitle].mkv", + "result": { + "anime_title": "Princess Connect! Re - Dive", + "episode_number": "02", + "file_extension": "mkv", + "file_name": "[Erai-raws] Princess Connect! Re - Dive - 02[1080p][Multiple Subtitle]", + "release_group": "Erai-raws", + "video_resolution": "1080p" + } + }, + { + "filename": "[Erai-raws] Kitsutsuki Tanteidokoro - 01[1080p][Multiple Subtitle].mkv", + "result": { + "anime_title": "Kitsutsuki Tanteidokoro", + "episode_number": "01", + "file_extension": "mkv", + "file_name": "[Erai-raws] Kitsutsuki Tanteidokoro - 01[1080p][Multiple Subtitle]", + "release_group": "Erai-raws", + "video_resolution": "1080p" + } + }, + { + "filename": "[Erai-raws] Fate Grand Order - Zettai Majuu Sensen Babylonia - 20[1080p][Multiple Subtitle].mkv", + "result": { + "anime_title": "Fate Grand Order - Zettai Majuu Sensen Babylonia", + "episode_number": "20", + "file_extension": "mkv", + "file_name": "[Erai-raws] Fate Grand Order - Zettai Majuu Sensen Babylonia - 20[1080p][Multiple Subtitle]", + "release_group": "Erai-raws", + "video_resolution": "1080p" + } + }, + { + "filename": "[Erai-raws] 22 - 7 - 10[1080p][Multiple Subtitle].mkv", + "result": { + "anime_title": "22", + "episode_number": "7", + "episode_title": "10", + "file_extension": "mkv", + "file_name": "[Erai-raws] 22 - 7 - 10[1080p][Multiple Subtitle]", + "release_group": "Erai-raws", + "video_resolution": "1080p" + } + }, + { + "filename": "[Erai-raws] Princess Connect! Re - Dive - 02[720p][Multiple Subtitle].mkv", + "result": { + "anime_title": "Princess Connect! Re - Dive", + "episode_number": "02", + "file_extension": "mkv", + "file_name": "[Erai-raws] Princess Connect! Re - Dive - 02[720p][Multiple Subtitle]", + "release_group": "Erai-raws", + "video_resolution": "720p" + } + }, + { + "filename": "[Erai-raws] Fruits Basket 2nd Season - 02[1080p].mkv", + "result": { + "anime_season": "2", + "anime_title": "Fruits Basket", + "episode_number": "02", + "file_extension": "mkv", + "file_name": "[Erai-raws] Fruits Basket 2nd Season - 02[1080p]", + "release_group": "Erai-raws", + "video_resolution": "1080p" + } + }, + { + "filename": "[Erai-raws] Fruits Basket 2nd Season - 02[720p].mkv", + "result": { + "anime_season": "2", + "anime_title": "Fruits Basket", + "episode_number": "02", + "file_extension": "mkv", + "file_name": "[Erai-raws] Fruits Basket 2nd Season - 02[720p]", + "release_group": "Erai-raws", + "video_resolution": "720p" + } + } +] \ No newline at end of file diff --git a/test/bindings/nameParser/index.spec.js b/test/bindings/nameParser/index.spec.js new file mode 100644 index 0000000..b2a27f6 --- /dev/null +++ b/test/bindings/nameParser/index.spec.js @@ -0,0 +1,33 @@ +const chai = require('chai') + +const should = chai.should() +const expect = chai.expect + +module.exports = function () { + describe('Anitomy bindings', function () { + this.bindings = null + + it('should successfullly import the bindings', function () { + try { + this.bindings = require('../../../bindings/build/Release/kawaparser.node') + } catch (e) { + should.fail('Could not import Anitomy bindings: ' + e.stack) + } + }) + + it('should be formatted properly', function () { + this.bindings.should.be.an('object') + this.bindings.should.include.keys('parseName') + this.bindings.parseName.should.be.a('function') + }) + + it('should be able to parse some filenames', function () { + const data = require('./data.json') + const parse = this.bindings.parseName + + data.forEach(({ filename, result }) => { + expect(parse(filename)).to.eql(result) + }) + }) + }) +} diff --git a/test/bindings/torrent/index.spec.js b/test/bindings/torrent/index.spec.js new file mode 100644 index 0000000..18fde22 --- /dev/null +++ b/test/bindings/torrent/index.spec.js @@ -0,0 +1,26 @@ +const chai = require('chai') + +const should = chai.should() + +module.exports = function () { + describe('Libtorrent bindings', function () { + this.bindings = null + + it('should successfullly import the bindings', function () { + try { + this.bindings = require('../../../bindings/build/Release/kawatorrent.node') + } catch (e) { + should.fail('Could not import Libtorrent bindings: ' + e.stack) + } + }) + + it('should be formatted properly', function () { + this.bindings.should.be.an('object') + this.bindings.should.include.keys('torrent') + this.bindings.torrent.should.be.a('object') + this.bindings.torrent.should.include.keys(['Client', 'version']) + this.bindings.torrent.version.should.be.a('string') + this.bindings.torrent.Client.should.be.a('function') + }) + }) +} diff --git a/test/index.spec.js b/test/index.spec.js index 15559d7..ccdfc01 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -13,6 +13,10 @@ * - Webdriver.io: https://webdriver.io/docs/api/browser/waitUntil.html */ +describe('KawaBinds main test routine', function () { + require('./bindings') +}) + describe('KawAnime main test routine', function () { this.timeout(30000)