UNPKG

identify-media

Version:

Analyse file path and content to make search criteria for media APIs

57 lines (52 loc) 1.94 kB
import * as clean from '../../src/lib/cleanString'; describe('Test Clean String methods', () => { describe('Test strip parenthesis', () => { test.each([ ['Test', 'Test'], ['[something.com] Test', ' Test'], ['(a) (b) (c) test', ' test'], ['', ''], ['{a}(x)[q]test', 'test'], ['test (not {this} not) test', 'test test'], ])('should strip %s to %s', (input, result) => { expect(clean.stripParenthesis(input)).toBe(result); }); }); describe('Test trim end', () => { test.each([ ['', ''], ['(', ''], ['series (2020) ', 'series (2020)'], ['movie (', 'movie'], ['series - ', 'series'], ['tick,.tick...boom! (', 'tick,.tick...boom!'] ])('should strip %s to %s', (input, result) => { expect(clean.trimEnd(input)).toBe(result); }); }); describe('Test set spaces', () => { test.each([ ['', ''], ['this.is.a.test', 'this is a test'], ['._._moo-cow?_._.', 'moo cow?'], ['tick,.tick...BOOM!', 'tick, tick...BOOM!'], ['...and.justice.for.all', '...and justice for all'], ['test.....wow', 'test ... wow'], ['....', '...'], ['.....', '...'], ])('should replace %s to %s', (input, result) => { expect(clean.setSpaces(input)).toBe(result); }); }); describe('Strip seasons', () => { test.each([ ['', undefined], ['Monk S01-S08', 'Monk '], ['season 3 (', undefined], ['Lucifer - Season 5', 'Lucifer - '], ['MACGYVER - Complete Season 3 S03 (2018', 'MACGYVER - '] ])('should replace %s to %s', (input, result) => { expect(clean.stripSeasons(input)).toBe(result); }); }); });