1
0
mirror of https://github.com/devfake/flox.git synced 2024-11-12 13:22:28 +01:00

Integrate eslint (#20)

* Add eslint

* Clean up code

* Add eslint to travis
This commit is contained in:
Tim Meier 2017-01-04 10:34:12 +01:00 committed by Tim Meier
parent 70af78ab27
commit f831e5d69b
12 changed files with 394 additions and 397 deletions

View File

@ -20,6 +20,7 @@ services:
script:
- (cd backend && phpunit)
- (cd $FLOX_FILE_PARSER && npm test)
- (cd $FLOX_FILE_PARSER && npm run eslint)
before_install:
- mysql -e 'create database flox_file_parser_test;'

View File

@ -0,0 +1,30 @@
{
"env": {
"node": true,
"mocha": true,
"commonjs": true,
"es6": true
},
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module"
},
"rules": {
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"double"
],
"semi": [
"error",
"never"
]
}
}

View File

@ -1,121 +1,121 @@
module.exports = [
{
"id" : 38,
"src" : __dirname + "/movies/Star Wars/StarWars Episode VI Return of The Jedi 1080p BDRip/StarWars.Episode.VI.Return.of.The.Jedi.1080p.BDRip.mp4",
"removed" : "2017-01-02 13:18:24",
"createdAt" : "2016-01-01 13:16:47",
"updatedAt" : "2017-01-02 13:18:24",
"category" : "movies",
"extension" : "mp4",
"filename" : "StarWars.Episode.VI.Return.of.The.Jedi.1080p.BDRip",
"name" : "starwars episode vi return of the jedi",
"year" : null,
"tags" : "hd,1080p",
"episode_number" : null,
"season_number" : null,
"tv_title" : null,
"subtitles" : null
},
{
"id" : 39,
"src" : __dirname + "/movies/Warcraft.2016.720p.WEB-DL/Warcraft.2016.720p.WEB-DL.mkv",
"removed" : "2017-01-02 13:20:48",
"createdAt" : "2016-01-01 13:16:47",
"updatedAt" : "2017-01-02 13:20:48",
"category" : "movies",
"extension" : "mkv",
"filename" : "Warcraft.2016.720p.WEB-DL",
"name" : "warcraft",
"year" : 2016,
"tags" : "720p",
"episode_number" : null,
"season_number" : null,
"tv_title" : null,
"subtitles" : __dirname + "/movies/Warcraft.2016.720p.WEB-DL/Warcraft.2016.720p.WEB-DL.srt"
},
{
"id" : 40,
"src" : __dirname + "/movies/Star Wars/StarWars Episode VI Return of The Jedi 1080p BDRip/StarWars.Episode.VI.Return.of.The.Jedi.1080p.BDRip.mkv",
"removed" : "2017-01-02 13:18:54",
"createdAt" : "2017-01-02 13:18:24",
"updatedAt" : "2017-01-02 13:18:54",
"category" : "movies",
"extension" : "mkv",
"filename" : "StarWars.Episode.VI.Return.of.The.Jedi.1080p.BDRip",
"name" : "starwars episode vi return of the jedi",
"year" : null,
"tags" : "hd,1080p",
"episode_number" : null,
"season_number" : null,
"tv_title" : null,
"subtitles" : null
},
{
"id" : 41,
"src" : __dirname + "/movies/Star Wars/StarWars Episode VI Return of The Jedi 1080p BDRip/StarWars.Episode.VI.Return.of.The.Jedi.1080p.BDRip.mp4",
"removed" : "2017-01-02 13:21:12",
"createdAt" : "2017-01-02 13:18:54",
"updatedAt" : "2017-01-02 13:21:12",
"category" : "movies",
"extension" : "mp4",
"filename" : "StarWars.Episode.VI.Return.of.The.Jedi.1080p.BDRip",
"name" : "starwars episode vi return of the jedi",
"year" : null,
"tags" : "hd,1080p",
"episode_number" : null,
"season_number" : null,
"tv_title" : null,
"subtitles" : null
},
{
"id" : 42,
"src" : __dirname + "/movies/subfolder/Warcraft.2016.720p.WEB-DL/Warcraft.2016.720p.WEB-DL.mkv",
"removed" : "2017-01-02 13:21:12",
"createdAt" : "2017-01-02 13:20:48",
"updatedAt" : "2017-01-02 13:21:12",
"category" : "movies",
"extension" : "mkv",
"filename" : "Warcraft.2016.720p.WEB-DL",
"name" : "warcraft",
"year" : 2016,
"tags" : "720p",
"episode_number" : null,
"season_number" : null,
"tv_title" : null,
"subtitles" : __dirname + "/movies/subfolder/Warcraft.2016.720p.WEB-DL/Warcraft.2016.720p.WEB-DL.srt"
},
{
"id" : 43,
"src" : __dirname + "/movies/Star Wars/StarWars Episode VI Return of The Jedi 1080p BDRip/StarWars.Episode.VI.Return.of.The.Jedi.1080p.BDRip.mp4",
"removed" : null,
"createdAt" : "2017-01-02 13:21:21",
"updatedAt" : "2017-01-02 13:21:21",
"category" : "movies",
"extension" : "mp4",
"filename" : "StarWars.Episode.VI.Return.of.The.Jedi.1080p.BDRip",
"name" : "starwars episode vi return of the jedi",
"year" : null,
"tags" : "hd,1080p",
"episode_number" : null,
"season_number" : null,
"tv_title" : null,
"subtitles" : null
},
{
"id" : 44,
"src" : __dirname + "/movies/Warcraft.2016.720p.WEB-DL/Warcraft.2016.720p.WEB-DL.mkv",
"removed" : null,
"createdAt" : "2017-01-02 13:21:21",
"updatedAt" : "2017-01-02 13:21:21",
"category" : "movies",
"extension" : "mkv",
"filename" : "Warcraft.2016.720p.WEB-DL",
"name" : "warcraft",
"year" : 2016,
"tags" : "720p",
"episode_number" : null,
"season_number" : null,
"tv_title" : null,
"subtitles" : __dirname + "/movies/Warcraft.2016.720p.WEB-DL/Warcraft.2016.720p.WEB-DL.srt"
}
{
"id" : 38,
"src" : __dirname + "/movies/Star Wars/StarWars Episode VI Return of The Jedi 1080p BDRip/StarWars.Episode.VI.Return.of.The.Jedi.1080p.BDRip.mp4",
"removed" : "2017-01-02 13:18:24",
"createdAt" : "2016-01-01 13:16:47",
"updatedAt" : "2017-01-02 13:18:24",
"category" : "movies",
"extension" : "mp4",
"filename" : "StarWars.Episode.VI.Return.of.The.Jedi.1080p.BDRip",
"name" : "starwars episode vi return of the jedi",
"year" : null,
"tags" : "hd,1080p",
"episode_number" : null,
"season_number" : null,
"tv_title" : null,
"subtitles" : null
},
{
"id" : 39,
"src" : __dirname + "/movies/Warcraft.2016.720p.WEB-DL/Warcraft.2016.720p.WEB-DL.mkv",
"removed" : "2017-01-02 13:20:48",
"createdAt" : "2016-01-01 13:16:47",
"updatedAt" : "2017-01-02 13:20:48",
"category" : "movies",
"extension" : "mkv",
"filename" : "Warcraft.2016.720p.WEB-DL",
"name" : "warcraft",
"year" : 2016,
"tags" : "720p",
"episode_number" : null,
"season_number" : null,
"tv_title" : null,
"subtitles" : __dirname + "/movies/Warcraft.2016.720p.WEB-DL/Warcraft.2016.720p.WEB-DL.srt"
},
{
"id" : 40,
"src" : __dirname + "/movies/Star Wars/StarWars Episode VI Return of The Jedi 1080p BDRip/StarWars.Episode.VI.Return.of.The.Jedi.1080p.BDRip.mkv",
"removed" : "2017-01-02 13:18:54",
"createdAt" : "2017-01-02 13:18:24",
"updatedAt" : "2017-01-02 13:18:54",
"category" : "movies",
"extension" : "mkv",
"filename" : "StarWars.Episode.VI.Return.of.The.Jedi.1080p.BDRip",
"name" : "starwars episode vi return of the jedi",
"year" : null,
"tags" : "hd,1080p",
"episode_number" : null,
"season_number" : null,
"tv_title" : null,
"subtitles" : null
},
{
"id" : 41,
"src" : __dirname + "/movies/Star Wars/StarWars Episode VI Return of The Jedi 1080p BDRip/StarWars.Episode.VI.Return.of.The.Jedi.1080p.BDRip.mp4",
"removed" : "2017-01-02 13:21:12",
"createdAt" : "2017-01-02 13:18:54",
"updatedAt" : "2017-01-02 13:21:12",
"category" : "movies",
"extension" : "mp4",
"filename" : "StarWars.Episode.VI.Return.of.The.Jedi.1080p.BDRip",
"name" : "starwars episode vi return of the jedi",
"year" : null,
"tags" : "hd,1080p",
"episode_number" : null,
"season_number" : null,
"tv_title" : null,
"subtitles" : null
},
{
"id" : 42,
"src" : __dirname + "/movies/subfolder/Warcraft.2016.720p.WEB-DL/Warcraft.2016.720p.WEB-DL.mkv",
"removed" : "2017-01-02 13:21:12",
"createdAt" : "2017-01-02 13:20:48",
"updatedAt" : "2017-01-02 13:21:12",
"category" : "movies",
"extension" : "mkv",
"filename" : "Warcraft.2016.720p.WEB-DL",
"name" : "warcraft",
"year" : 2016,
"tags" : "720p",
"episode_number" : null,
"season_number" : null,
"tv_title" : null,
"subtitles" : __dirname + "/movies/subfolder/Warcraft.2016.720p.WEB-DL/Warcraft.2016.720p.WEB-DL.srt"
},
{
"id" : 43,
"src" : __dirname + "/movies/Star Wars/StarWars Episode VI Return of The Jedi 1080p BDRip/StarWars.Episode.VI.Return.of.The.Jedi.1080p.BDRip.mp4",
"removed" : null,
"createdAt" : "2017-01-02 13:21:21",
"updatedAt" : "2017-01-02 13:21:21",
"category" : "movies",
"extension" : "mp4",
"filename" : "StarWars.Episode.VI.Return.of.The.Jedi.1080p.BDRip",
"name" : "starwars episode vi return of the jedi",
"year" : null,
"tags" : "hd,1080p",
"episode_number" : null,
"season_number" : null,
"tv_title" : null,
"subtitles" : null
},
{
"id" : 44,
"src" : __dirname + "/movies/Warcraft.2016.720p.WEB-DL/Warcraft.2016.720p.WEB-DL.mkv",
"removed" : null,
"createdAt" : "2017-01-02 13:21:21",
"updatedAt" : "2017-01-02 13:21:21",
"category" : "movies",
"extension" : "mkv",
"filename" : "Warcraft.2016.720p.WEB-DL",
"name" : "warcraft",
"year" : 2016,
"tags" : "720p",
"episode_number" : null,
"season_number" : null,
"tv_title" : null,
"subtitles" : __dirname + "/movies/Warcraft.2016.720p.WEB-DL/Warcraft.2016.720p.WEB-DL.srt"
}
]

View File

@ -129,19 +129,19 @@ var fetch = module.exports.fetch = {
var expectedTv = module.exports.expectedTv = fetch.tv
var expectedMovies = module.exports.expectedMovies = fetch.movies
var expected_bb_s1_e1 = module.exports.expected_bb_s1_e1 = expectedTv[0]
var expected_bb_s1_e2 = module.exports.expected_bb_s1_e2 = expectedTv[1]
var expected_bb_s2_e1 = module.exports.expected_bb_s2_e1 = expectedTv[2]
var expected_bb_s2_e2 = module.exports.expected_bb_s2_e2 = expectedTv[3]
module.exports.expected_bb_s1_e1 = expectedTv[0]
module.exports.expected_bb_s1_e2 = expectedTv[1]
module.exports.expected_bb_s2_e1 = expectedTv[2]
module.exports.expected_bb_s2_e2 = expectedTv[3]
var expected_got_s1_e1 = module.exports.expected_got_s1_e1 = expectedTv[4]
var expected_got_s1_e2 = module.exports.expected_got_s1_e2 = expectedTv[5]
var expected_got_s2_e1 = module.exports.expected_got_s2_e1 = expectedTv[6]
var expected_got_s2_e2 = module.exports.expected_got_s2_e2 = expectedTv[7]
module.exports.expected_got_s1_e1 = expectedTv[4]
module.exports.expected_got_s1_e2 = expectedTv[5]
module.exports.expected_got_s2_e1 = expectedTv[6]
module.exports.expected_got_s2_e2 = expectedTv[7]
var expected_got_seasons = module.exports.expected_got_seasons = 2
var expected_bb_seasons = module.exports.expected_bb_seasons = 2
module.exports.expected_got_seasons = 2
module.exports.expected_bb_seasons = 2
var expected_sw = module.exports.expected_sw = expectedMovies[0]
var expected_wc = module.exports.expected_wc = expectedMovies[1]
module.exports.expected_sw = expectedMovies[0]
module.exports.expected_wc = expectedMovies[1]

View File

@ -1,189 +1,189 @@
module.exports = [
{
"id" : 13,
"src" : __dirname + "/tv/Breaking Bad/S1/1.mkv",
"removed" : "2017-01-01 13:20:32",
"createdAt" : "2016-12-31 13:06:15",
"updatedAt" : "2017-01-01 13:20:32",
"category" : "tv",
"extension" : "mkv",
"filename" : "1",
"name" : "Breaking Bad",
"year" : null,
"tags" : null,
"episode_number" : 1,
"season_number" : 1,
"tv_title" : "Breaking Bad",
"subtitles" : __dirname + "/tv/Breaking Bad/S1/1.srt"
},
{
"id" : 14,
"src" : __dirname + "/tv/Breaking Bad/S1/2.mkv",
"removed" : null,
"createdAt" : "2016-12-31 13:06:15",
"updatedAt" : "2016-12-31 13:06:15",
"category" : "tv",
"extension" : "mkv",
"filename" : "2",
"name" : "Breaking Bad",
"year" : null,
"tags" : null,
"episode_number" : 2,
"season_number" : 1,
"tv_title" : "Breaking Bad",
"subtitles" : __dirname + "/tv/Breaking Bad/S1/2.srt"
},
{
"id" : 15,
"src" : __dirname + "/tv/Breaking Bad/s2/1.mp4",
"removed" : null,
"createdAt" : "2016-12-31 13:06:15",
"updatedAt" : "2016-12-31 13:06:15",
"category" : "tv",
"extension" : "mp4",
"filename" : "1",
"name" : "Breaking Bad",
"year" : null,
"tags" : null,
"episode_number" : 1,
"season_number" : 2,
"tv_title" : "Breaking Bad",
"subtitles" : __dirname + "/tv/Breaking Bad/s2/1.srt"
},
{
"id" : 16,
"src" : __dirname + "/tv/Breaking Bad/s2/2.mkv",
"removed" : "2017-01-01 15:12:58",
"createdAt" : "2016-12-31 13:06:15",
"updatedAt" : "2017-01-01 15:12:58",
"category" : "tv",
"extension" : "mkv",
"filename" : "2",
"name" : "Breaking Bad",
"year" : null,
"tags" : null,
"episode_number" : 2,
"season_number" : 2,
"tv_title" : "Breaking Bad",
"subtitles" : __dirname + "/tv/Breaking Bad/s2/2.srt"
},
{
"id" : 17,
"src" : __dirname + "/tv/Game of Thrones/S2/1.mkv",
"removed" : null,
"createdAt" : "2016-12-31 13:06:15",
"updatedAt" : "2016-12-31 13:06:15",
"category" : "tv",
"extension" : "mkv",
"filename" : "1",
"name" : "Game of Thrones",
"year" : null,
"tags" : null,
"episode_number" : 1,
"season_number" : 2,
"tv_title" : "Game of Thrones",
"subtitles" : null
},
{
"id" : 18,
"src" : __dirname + "/tv/Game of Thrones/S2/2.mkv",
"removed" : null,
"createdAt" : "2016-12-31 13:06:15",
"updatedAt" : "2016-12-31 13:06:15",
"category" : "tv",
"extension" : "mkv",
"filename" : "2",
"name" : "Game of Thrones",
"year" : null,
"tags" : null,
"episode_number" : 2,
"season_number" : 2,
"tv_title" : "Game of Thrones",
"subtitles" : null
},
{
"id" : 19,
"src" : __dirname + "/tv/Game of Thrones/s1/1.mkv",
"removed" : null,
"createdAt" : "2016-12-31 13:06:15",
"updatedAt" : "2016-12-31 13:06:15",
"category" : "tv",
"extension" : "mkv",
"filename" : "1",
"name" : "Game of Thrones",
"year" : null,
"tags" : null,
"episode_number" : 1,
"season_number" : 1,
"tv_title" : "Game of Thrones",
"subtitles" : null
},
{
"id" : 20,
"src" : __dirname + "/tv/Game of Thrones/s1/2.mp4",
"removed" : null,
"createdAt" : "2016-12-31 13:06:15",
"updatedAt" : "2016-12-31 13:06:15",
"category" : "tv",
"extension" : "mp4",
"filename" : "2",
"name" : "Game of Thrones",
"year" : null,
"tags" : null,
"episode_number" : 2,
"season_number" : 1,
"tv_title" : "Game of Thrones",
"subtitles" : null
},
{
"id" : 24,
"src" : __dirname + "/tv/Breaking Bad/S1/1.mp4",
"removed" : "2017-01-01 15:07:09",
"createdAt" : "2017-01-01 13:20:32",
"updatedAt" : "2017-01-01 15:07:09",
"category" : "tv",
"extension" : "mp4",
"filename" : "1",
"name" : "Breaking Bad",
"year" : null,
"tags" : null,
"episode_number" : 1,
"season_number" : 1,
"tv_title" : "Breaking Bad",
"subtitles" : __dirname + "/tv/Breaking Bad/S1/1.srt"
},
{
"id" : 26,
"src" : __dirname + "/tv/Breaking Bad/S1/1.mkv",
"removed" : null,
"createdAt" : "2017-01-01 15:07:09",
"updatedAt" : "2017-01-01 15:07:09",
"category" : "tv",
"extension" : "mkv",
"filename" : "1",
"name" : "Breaking Bad",
"year" : null,
"tags" : null,
"episode_number" : 1,
"season_number" : 1,
"tv_title" : "Breaking Bad",
"subtitles" : __dirname + "/tv/Breaking Bad/S1/1.srt"
},
{
"id" : 27,
"src" : __dirname + "/tv/Breaking Bad/s2/2.mkv",
"removed" : null,
"createdAt" : "2017-01-02 12:16:34",
"updatedAt" : "2017-01-02 12:16:34",
"category" : "tv",
"extension" : "mkv",
"filename" : "2",
"name" : "Breaking Bad",
"year" : null,
"tags" : null,
"episode_number" : 2,
"season_number" : 2,
"tv_title" : "Breaking Bad",
"subtitles" : __dirname + "/tv/Breaking Bad/s2/2.srt"
}
{
"id" : 13,
"src" : __dirname + "/tv/Breaking Bad/S1/1.mkv",
"removed" : "2017-01-01 13:20:32",
"createdAt" : "2016-12-31 13:06:15",
"updatedAt" : "2017-01-01 13:20:32",
"category" : "tv",
"extension" : "mkv",
"filename" : "1",
"name" : "Breaking Bad",
"year" : null,
"tags" : null,
"episode_number" : 1,
"season_number" : 1,
"tv_title" : "Breaking Bad",
"subtitles" : __dirname + "/tv/Breaking Bad/S1/1.srt"
},
{
"id" : 14,
"src" : __dirname + "/tv/Breaking Bad/S1/2.mkv",
"removed" : null,
"createdAt" : "2016-12-31 13:06:15",
"updatedAt" : "2016-12-31 13:06:15",
"category" : "tv",
"extension" : "mkv",
"filename" : "2",
"name" : "Breaking Bad",
"year" : null,
"tags" : null,
"episode_number" : 2,
"season_number" : 1,
"tv_title" : "Breaking Bad",
"subtitles" : __dirname + "/tv/Breaking Bad/S1/2.srt"
},
{
"id" : 15,
"src" : __dirname + "/tv/Breaking Bad/s2/1.mp4",
"removed" : null,
"createdAt" : "2016-12-31 13:06:15",
"updatedAt" : "2016-12-31 13:06:15",
"category" : "tv",
"extension" : "mp4",
"filename" : "1",
"name" : "Breaking Bad",
"year" : null,
"tags" : null,
"episode_number" : 1,
"season_number" : 2,
"tv_title" : "Breaking Bad",
"subtitles" : __dirname + "/tv/Breaking Bad/s2/1.srt"
},
{
"id" : 16,
"src" : __dirname + "/tv/Breaking Bad/s2/2.mkv",
"removed" : "2017-01-01 15:12:58",
"createdAt" : "2016-12-31 13:06:15",
"updatedAt" : "2017-01-01 15:12:58",
"category" : "tv",
"extension" : "mkv",
"filename" : "2",
"name" : "Breaking Bad",
"year" : null,
"tags" : null,
"episode_number" : 2,
"season_number" : 2,
"tv_title" : "Breaking Bad",
"subtitles" : __dirname + "/tv/Breaking Bad/s2/2.srt"
},
{
"id" : 17,
"src" : __dirname + "/tv/Game of Thrones/S2/1.mkv",
"removed" : null,
"createdAt" : "2016-12-31 13:06:15",
"updatedAt" : "2016-12-31 13:06:15",
"category" : "tv",
"extension" : "mkv",
"filename" : "1",
"name" : "Game of Thrones",
"year" : null,
"tags" : null,
"episode_number" : 1,
"season_number" : 2,
"tv_title" : "Game of Thrones",
"subtitles" : null
},
{
"id" : 18,
"src" : __dirname + "/tv/Game of Thrones/S2/2.mkv",
"removed" : null,
"createdAt" : "2016-12-31 13:06:15",
"updatedAt" : "2016-12-31 13:06:15",
"category" : "tv",
"extension" : "mkv",
"filename" : "2",
"name" : "Game of Thrones",
"year" : null,
"tags" : null,
"episode_number" : 2,
"season_number" : 2,
"tv_title" : "Game of Thrones",
"subtitles" : null
},
{
"id" : 19,
"src" : __dirname + "/tv/Game of Thrones/s1/1.mkv",
"removed" : null,
"createdAt" : "2016-12-31 13:06:15",
"updatedAt" : "2016-12-31 13:06:15",
"category" : "tv",
"extension" : "mkv",
"filename" : "1",
"name" : "Game of Thrones",
"year" : null,
"tags" : null,
"episode_number" : 1,
"season_number" : 1,
"tv_title" : "Game of Thrones",
"subtitles" : null
},
{
"id" : 20,
"src" : __dirname + "/tv/Game of Thrones/s1/2.mp4",
"removed" : null,
"createdAt" : "2016-12-31 13:06:15",
"updatedAt" : "2016-12-31 13:06:15",
"category" : "tv",
"extension" : "mp4",
"filename" : "2",
"name" : "Game of Thrones",
"year" : null,
"tags" : null,
"episode_number" : 2,
"season_number" : 1,
"tv_title" : "Game of Thrones",
"subtitles" : null
},
{
"id" : 24,
"src" : __dirname + "/tv/Breaking Bad/S1/1.mp4",
"removed" : "2017-01-01 15:07:09",
"createdAt" : "2017-01-01 13:20:32",
"updatedAt" : "2017-01-01 15:07:09",
"category" : "tv",
"extension" : "mp4",
"filename" : "1",
"name" : "Breaking Bad",
"year" : null,
"tags" : null,
"episode_number" : 1,
"season_number" : 1,
"tv_title" : "Breaking Bad",
"subtitles" : __dirname + "/tv/Breaking Bad/S1/1.srt"
},
{
"id" : 26,
"src" : __dirname + "/tv/Breaking Bad/S1/1.mkv",
"removed" : null,
"createdAt" : "2017-01-01 15:07:09",
"updatedAt" : "2017-01-01 15:07:09",
"category" : "tv",
"extension" : "mkv",
"filename" : "1",
"name" : "Breaking Bad",
"year" : null,
"tags" : null,
"episode_number" : 1,
"season_number" : 1,
"tv_title" : "Breaking Bad",
"subtitles" : __dirname + "/tv/Breaking Bad/S1/1.srt"
},
{
"id" : 27,
"src" : __dirname + "/tv/Breaking Bad/s2/2.mkv",
"removed" : null,
"createdAt" : "2017-01-02 12:16:34",
"updatedAt" : "2017-01-02 12:16:34",
"category" : "tv",
"extension" : "mkv",
"filename" : "2",
"name" : "Breaking Bad",
"year" : null,
"tags" : null,
"episode_number" : 2,
"season_number" : 2,
"tv_title" : "Breaking Bad",
"subtitles" : __dirname + "/tv/Breaking Bad/s2/2.srt"
}
]

View File

@ -1,3 +1,4 @@
/* globals sandbox, request */
import chai, { expect } from "chai"
import db from "../database/models"
import chaiAsPromised from "chai-as-promised"
@ -15,35 +16,31 @@ describe("HTTP Server", () => {
process.env.MOVIES_ROOT = __dirname + "/fixtures/movies"
let i = 0
file_history.addHook('beforeCreate', 'stubCreatedAt', (row, options) => {
file_history.addHook("beforeCreate", "stubCreatedAt", (row) => {
row.createdAt = Date.parse(new Date("01.01.2000")) + (i += 1000)
row.updatedAt = Date.parse(new Date("01.01.2000")) + i
})
})
afterEach(() => {
file_history.removeHook('beforeCreate', 'stubCreatedAt')
file_history.removeHook("beforeCreate", "stubCreatedAt")
})
describe("GET: fetch", () => {
const path = "/fetch"
it("should succeed", (done) => {
request.get(path)
.expect(200, done)
it("should succeed", () => {
return request.get(path)
.expect(200)
})
it("returns valid json", (done) => {
request.get(path)
.expect('Content-Type', /json/)
.end((err, res) => {
if(err) return done(err)
done()
})
it("returns valid json", () => {
return request.get(path)
.expect("Content-Type", /json/)
})
it("should contain movies", (done) => {
request.get(path)
it("should contain movies", () => {
return request.get(path)
.expect(res => {
const stringified = JSON.stringify(res.body)
@ -52,14 +49,10 @@ describe("HTTP Server", () => {
expect(res.body).to.have.property("movies")
expect(res.body).to.be.a("object")
})
.end((err) => {
if (err) return done(err)
done()
})
})
it("should contain tv", (done) => {
request.get(path)
it("should contain tv", () => {
return request.get(path)
.expect(res => {
const stringified = JSON.stringify(res.body)
@ -68,10 +61,6 @@ describe("HTTP Server", () => {
expect(res.body).to.have.property("tv")
expect(res.body).to.be.a("object")
})
.end((err) => {
if (err) return done(err)
done()
})
})
})
@ -85,7 +74,7 @@ describe("HTTP Server", () => {
it("returns valid json", () => {
return request.get(path)
.expect('Content-Type', /json/)
.expect("Content-Type", /json/)
})
it("should only include tv", () => {
@ -113,7 +102,7 @@ describe("HTTP Server", () => {
it("returns valid json", () => {
return request.get(path)
.expect('Content-Type', /json/)
.expect("Content-Type", /json/)
})
it("should only include movies", () => {
@ -141,7 +130,7 @@ describe("HTTP Server", () => {
it("should return valid json", () => {
return request.get(path)
.expect('Content-Type', /json/)
.expect("Content-Type", /json/)
})
})
@ -155,7 +144,7 @@ describe("HTTP Server", () => {
it("should return valid json", () => {
return request.get(path)
.expect('Content-Type', /json/)
.expect("Content-Type", /json/)
})
context("should return only changes since the given timestamp", () => {
@ -164,7 +153,7 @@ describe("HTTP Server", () => {
})
it("with empty db", () => {
file_history.removeHook('beforeCreate', 'stubCreatedAt')
file_history.removeHook("beforeCreate", "stubCreatedAt")
return request.get(path).expect((res) => {
expect(res.body).to.have.deep.members(fixturesResultFetch.expectedMovies)
@ -388,7 +377,7 @@ describe("HTTP Server", () => {
it("should return valid json", () => {
return request.get(path)
.expect('Content-Type', /json/)
.expect("Content-Type", /json/)
})
context("should return only changes since the given timestamp", () => {
@ -397,7 +386,7 @@ describe("HTTP Server", () => {
})
it("with empty db", () => {
file_history.removeHook('beforeCreate', 'stubCreatedAt')
file_history.removeHook("beforeCreate", "stubCreatedAt")
return request.get(path).expect((res) => {
expect(res.body).to.have.deep.members(fixturesResultFetch.expectedTv)

View File

@ -1,12 +1,10 @@
/* globals sandbox */
import Parser from "./parser"
import { helper } from "./helper.js"
import { expect } from "chai"
import path from "path"
import db from "../../database/models"
import fixturesResultFetch from "../fixtures/fixturesResultFetch"
const { file_history } = db.sequelize.models
describe("helper", () => {
describe(".list", () => {
beforeEach(() => {
@ -61,7 +59,7 @@ describe("helper", () => {
})
it("takes a string as argument", () => {
const result = helper.normalizeNumber("0")
helper.normalizeNumber("0")
expect(helper.normalizeNumber.firstCall.args.length).to.be.not.equal(0)
expect(helper.normalizeNumber.firstCall.args[0]).to.be.a("string")
})
@ -132,8 +130,9 @@ describe("helper", () => {
{
result: helper.normalizeNumber("01.mkv"),
expected: 1
},
}
)
result.forEach((item) => {
expect(item.result).to.be.equal(item.expected)
})

View File

@ -1,5 +1,3 @@
const fs = require("fs")
const path = require("path")
const db = require("../../database/models")
const { file_history } = db.sequelize.models

View File

@ -1,3 +1,4 @@
/* globals sandbox */
import Parser from "./parser"
import { expect } from "chai"
import fs from "fs"
@ -16,7 +17,6 @@ describe("Parser (movies)", () => {
describe(".fetch()", () => {
let parser
const absolutePath = path.normalize(__dirname + "/../")
beforeEach(() => {
process.env.TV_ROOT = path.normalize(__dirname + "/../fixtures/tv")
@ -25,9 +25,6 @@ describe("Parser (movies)", () => {
})
context("using movie fixtures", () => {
let movies
let absoluteMoviePath = absolutePath + "fixtures/movies"
it("returns movies as an array", () => {
const result = parser.fetch()
return expect(result.movies).to.be.eventually.a("array")
@ -68,18 +65,18 @@ describe("Parser (movies)", () => {
beforeEach(() => {
let i = 0
file_history.addHook('beforeCreate', 'stubCreatedAt', (row, options) => {
file_history.addHook("beforeCreate", "stubCreatedAt", (row) => {
row.createdAt = Date.parse(new Date("01.01.2000")) + (i += 1000)
})
})
afterEach(() => {
file_history.removeHook('afterCreate', 'stubCreatedAt')
file_history.removeHook("afterCreate", "stubCreatedAt")
})
it("should have 2 entries", () => {
const { movies } = parser.fetch()
return movies.then((res) => {
return movies.then(() => {
return expect(file_history.count(filterTv)).to.be.eventually.equal(fixturesResultFetch.expectedMovies.length)
})
})
@ -88,7 +85,7 @@ describe("Parser (movies)", () => {
const result = parser.fetch()
const expectedSrc = fixturesResultFetch.expected_sw.src
return result.movies.then((res) => {
return result.movies.then(() => {
const result = file_history.findOne({
where: {
src: expectedSrc
@ -102,7 +99,7 @@ describe("Parser (movies)", () => {
const expectedSrc = fixturesResultFetch.expected_wc.src
const result = parser.fetch()
return result.movies.then((res) => {
return result.movies.then(() => {
const result = file_history.findOne({
where: {
src: expectedSrc
@ -135,7 +132,6 @@ describe("Parser (movies)", () => {
const srcWc = fixturesResultFetch.expected_wc.src
const expectedTimestamp = Date.parse("01 Jan 2001")
const expectedTime = new Date(expectedTimestamp)
sandbox.stub(Date, "now").returns(expectedTimestamp)
@ -188,7 +184,7 @@ describe("Parser (movies)", () => {
fs.unlinkSync(fixturesResultFetch.expected_wc.src)
const { movies } = parser.fetch()
return movies.then((res) => {
return movies.then(() => {
return Promise.all([
expect(file_history.count(getWc)).to.be.eventually.equal(1),
expect(file_history.findOne(getWc).then(getRemovedField)).to.eventually.be.eql(expectedTime)
@ -210,7 +206,7 @@ describe("Parser (movies)", () => {
const { movies } = parser.fetch()
return movies.then((res) => {
return movies.then(() => {
return Promise.all([
expect(file_history.count(getWc)).to.be.eventually.equal(1),
expect(file_history.findOne(getWc).then(getRemovedField)).to.eventually.be.eql(expectedTime),
@ -235,7 +231,7 @@ describe("Parser (movies)", () => {
fs.writeFileSync(fixturesResultFetch.expected_wc.src, "")
const { movies } = parser.fetch()
return movies.then((res) => {
return movies.then(() => {
return Promise.all([
expect(file_history.count(getWc)).to.be.eventually.equal(2),
expect(file_history.findOne(getWc).then(getRemovedField)).to.eventually.be.eql(expectedTime)

View File

@ -1,9 +1,6 @@
import Parser from "./parser"
import { expect } from "chai"
import path from "path"
import db from "../../database/models"
const { file_history } = db.sequelize.models
describe("Parser", () => {
beforeEach(() => {
@ -12,7 +9,7 @@ describe("Parser", () => {
})
it("exists", () => {
const parser = new Parser
new Parser
})
it("requires 2 env variables", () => {

View File

@ -1,3 +1,4 @@
/* global sandbox */
import Parser from "./parser"
import { expect } from "chai"
import fs from "fs"
@ -19,11 +20,6 @@ describe("Parser (tv)", () => {
const rootPath = "./app/fixtures"
const tvPath = rootPath + "/tv/"
const game_of_thrones = "Game of Thrones", breaking_bad = "Breaking Bad"
const got_seasons = ["s01", "s02"]
const bb_seasons = ["s01", "s02"]
const gotSeasonsPath = tvPath + game_of_thrones
const bbSeasonsPath = tvPath + breaking_bad
const absolutePath = path.normalize(__dirname + "/../")
const filterMovies = {
where: {
@ -41,7 +37,7 @@ describe("Parser (tv)", () => {
context("using tv fixtures", () => {
it("calls fs.readdirSync with the expected path", () => {
const result = parser.fetch()
parser.fetch()
const normalizedTvPath = fs.realpathSync(path.normalize(tvPath))
expect(fs.readdirSync.args[0][0]).to.equal(normalizedTvPath)
})
@ -132,15 +128,6 @@ describe("Parser (tv)", () => {
})
context("episodes", () => {
let got_s1_e1, got_s1_e2, got_s2_e1, got_s2_e2
let bb_s1_e1, bb_s1_e2, bb_s2_e1, bb_s2_e2
const absolutePath_got = absolutePath + "fixtures/tv/" + game_of_thrones
const absolutePath_got_s1 = absolutePath_got + "/" + "s1"
const absolutePath_got_s2 = absolutePath_got + "/" + "S2"
const absolutePath_bb = absolutePath + "fixtures/tv/" + breaking_bad
const absolutePath_bb_s1 = absolutePath_bb + "/" + "S1"
const absolutePath_bb_s2 = absolutePath_bb + "/" + "s2"
it("each season should have 2 episodes", () => {
expect(got_s1.length).to.be.equal(2)
expect(got_s2.length).to.be.equal(2)
@ -222,13 +209,13 @@ describe("Parser (tv)", () => {
context("database", () => {
beforeEach(() => {
let i = 0
file_history.addHook('beforeCreate', 'stubCreatedAt', (row, options) => {
file_history.addHook("beforeCreate", "stubCreatedAt", (row) => {
row.createdAt = Date.parse(new Date("01.01.2000")) + (i += 1000)
})
})
afterEach(() => {
file_history.removeHook('afterCreate', 'stubCreatedAt')
file_history.removeHook("afterCreate", "stubCreatedAt")
})
it("should have 8 entries", () => {
@ -253,11 +240,10 @@ describe("Parser (tv)", () => {
it("should save the current time in 'createdAt'", () => {
const expectedTimestamp = Date.parse("01 Jan 2000")
const expectedTime = new Date(expectedTimestamp) * 1
const expectedAdded = fixturesResultFetch.expectedTv.map((e) => expectedTime)
const { tv } = parser.fetch()
return tv.then((res) => {
return tv.then(() => {
return file_history.findAll(filterMovies).then((rows) => {
rows.forEach((row) => {
expect(row.createdAt * 1).to.be.closeTo(expectedTime, 10000)
@ -268,7 +254,6 @@ describe("Parser (tv)", () => {
it("should left 'removed' as null", () => {
const expectedTimestamp = Date.parse("01 Jan 2000")
const expectedTime = new Date(expectedTimestamp)
const getRemoved = (rows) => rows.map((e) => e.removed)
const expectedResult = fixturesResultFetch.expectedTv.map(() => null)
@ -296,7 +281,7 @@ describe("Parser (tv)", () => {
return fh.then(() => {
const { tv } = parser.fetch()
return tv.then((res) => {
return tv.then(() => {
return expect(file_history.count(filterMovies)).to.eventually.be.equal(8)
})
})
@ -331,7 +316,7 @@ describe("Parser (tv)", () => {
const expectedResultGot = [null, null, null, null]
const { tv } = parser.fetch()
return tv.then((res) => {
return tv.then(() => {
return Promise.all([
expect(file_history.count(getBB)).to.eventually.be.equal(4),
expect(file_history.findAll(getBB).then(getRemovedField)).to.eventually.be.eql(expectedResultBB),
@ -354,7 +339,7 @@ describe("Parser (tv)", () => {
const { tv } = parser.fetch()
return tv.then((res) => {
return tv.then(() => {
return Promise.all([
expect(file_history.count(getGOT)).to.be.eventually.equal(1),
expect(file_history.findOne(getGOT).then(getRemovedField)).to.eventually.be.eql(expectedTime),
@ -379,7 +364,7 @@ describe("Parser (tv)", () => {
fs.writeFileSync(fixturesResultFetch.expected_bb_s1_e1.src, "")
const { movies } = parser.fetch()
return movies.then((res) => {
return movies.then(() => {
return Promise.all([
expect(file_history.count(getBB)).to.be.eventually.equal(2),
expect(file_history.findOne(getBB).then(getRemovedField)).to.eventually.be.eql(expectedTime)

View File

@ -8,6 +8,7 @@
"test": "NODE_ENV=test mocha --compilers js:babel-core/register './app/**/*.spec.js'",
"coverage": "istanbul cover ./node_modules/.bin/_mocha 'app/**/*.js' -- --require babel-register",
"sequelize": "sequelize",
"eslint": "eslint './app/**/*.js'",
"test-watch": "NODE_ENV=test mocha --reporter min --watch --compilers js:babel-core/register './app/**/*.spec.js'"
},
"author": "",
@ -17,6 +18,7 @@
"babel-register": "^6.18.0",
"chai": "^3.5.0",
"chai-as-promised": "^6.0.0",
"eslint": "3.12.2",
"istanbul": "1.1.0-alpha.1",
"mocha": "^3.2.0",
"sequelize-cli": "^2.5.1",