diff --git a/spec/lib/episoder.spec.js b/spec/lib/episoder.spec.js new file mode 100644 index 000000000..c4726c0fd --- /dev/null +++ b/spec/lib/episoder.spec.js @@ -0,0 +1,44 @@ +var assert = require('assert'); +var episoder = require('../../lib/utils/episoder'); + +describe('Episoder', function () { + it('should detect data completely from filename', function () { + var filenames = [ + 'Community S01E04', + 'community s01e04', + 'Community 1x04', + 'Community 1-04', + 'Community Season 1 Episode 4', + 'Community Season 01 Episode 04', + 'Community 104.mp4' + ] + + for (var i = 0; i < filenames.length; i++) { + var result = episoder.parseFilename(filenames[i]); + + assert.equal(result.show, 'Community'); + assert.equal(result.season, 1); + assert.equal(result.episode, 4); + } + }); + + it('should use the season option', function () { + var result = episoder.parseFilename('Community S01E04', { season: 6 }); + assert.equal(result.season, 6); + }); + + it('should use the episode option', function () { + var result = episoder.parseFilename('Community S01E04', { episode: 16 }); + assert.equal(result.episode, 16); + }); + + it('should use the show option', function () { + var result = episoder.parseFilename('Community S01E04', { show: 'TEST' }); + assert.equal(result.show, 'Test'); + }); + + it('should use the offset option', function () { + var result = episoder.parseFilename('Test S01E04', { offset: 2 }); + assert.equal(result.episode, 6); + }); +}); diff --git a/spec/lib/title-cleaner.spec.js b/spec/lib/title-cleaner.spec.js index 3c6e51e53..6c7005631 100644 --- a/spec/lib/title-cleaner.spec.js +++ b/spec/lib/title-cleaner.spec.js @@ -4,6 +4,7 @@ var title_cleaner = require('../../lib/utils/title-cleaner'); describe('TitleCleaner', function () { it('should clean titles correctly', function () { var corrupt_titles = [ + '', 'A.Better.Life.LIMITED.DVDRip.XviD-TWiZTED', 'Aladdin[1992]DvDrip[Eng]-Stealthmaster', 'Austin Powers International Man of Mystery 1997.720p.x264.BRRip.GokU61', @@ -12,6 +13,7 @@ describe('TitleCleaner', function () { 'Fight.Club.iMMORTALS.(1999).xvid-R5.torrent' ] var cleaned_titles = [ + '', // Empty titles should not throw an error 'A Better Life LIMITED', 'Aladdin', 'Austin Powers International Man of Mystery GokU61',