-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
382a53a
commit f5632fb
Showing
7 changed files
with
248 additions
and
302 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,8 @@ | |
"packageManager": "[email protected]", | ||
"scripts": { | ||
"watch": "tsc --watch", | ||
"build": "tsc" | ||
"build": "tsc", | ||
"test": "vitest run" | ||
}, | ||
"dependencies": { | ||
"inversify": "^6.0.2", | ||
|
@@ -14,6 +15,7 @@ | |
"reflect-metadata": "^0.2.2" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^5.4.5" | ||
"typescript": "^5.4.5", | ||
"vitest": "^2.1.8" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export const Regexes = { | ||
VideoFile: /.mp4$/, | ||
VideoFile: /([\w\s]+)(?: \((\d{4})\))?.mpd$/, | ||
Thumbnail: /thumb\d*\.(jpg|jpeg|png)$/, | ||
Poster: /poster\d*\.(jpg|jpeg|png)$/, | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { describe, expect, test } from 'vitest'; | ||
import { Regexes } from '../src'; | ||
|
||
describe('Regexes', () => { | ||
test('Video file gets matches', () => { | ||
const res1 = Regexes.VideoFile.exec('Sample Movie (2015).mpd'); | ||
expect(res1).not.toBeNull(); | ||
expect(res1[0]).toEqual('Sample Movie (2015).mpd'); | ||
expect(res1[1]).toEqual('Sample Movie'); | ||
expect(res1[2]).toBe('2015'); | ||
|
||
const res2 = Regexes.VideoFile.exec('Sample Movie.mpd'); | ||
expect(res2).not.toBeNull(); | ||
expect(res2[0]).toEqual('Sample Movie.mpd'); | ||
expect(res2[1]).toEqual('Sample Movie'); | ||
expect(res2[2]).toBe(undefined); | ||
}); | ||
|
||
test('Thumbnail file gets matched', () => { | ||
expect(Regexes.Thumbnail.exec('thumb0.png')).not.toBeNull(); | ||
expect(Regexes.Thumbnail.exec('Sample Movie (2015)-thumb0.png')).not.toBeNull(); | ||
expect(Regexes.Thumbnail.exec('Sample Movie (2015)-thumb.jpg')).not.toBeNull(); | ||
expect(Regexes.Thumbnail.exec('Sample Movie (2015)-thumb.jpeg')).not.toBeNull(); | ||
}); | ||
|
||
test('Poster file gets matched', () => { | ||
expect(Regexes.Poster.exec('poster.jpg')).not.toBeNull(); | ||
expect(Regexes.Poster.exec('Sample Movie (2015)-poster.png')).not.toBeNull(); | ||
expect(Regexes.Poster.exec('Sample Movie (2015)-poster.jpg')).not.toBeNull(); | ||
expect(Regexes.Poster.exec('Sample Movie (2015)-poster.jpeg')).not.toBeNull(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.