Skip to content

Commit

Permalink
Add basic testing suite to core
Browse files Browse the repository at this point in the history
  • Loading branch information
undyingwraith committed Dec 11, 2024
1 parent 382a53a commit f5632fb
Show file tree
Hide file tree
Showing 7 changed files with 248 additions and 302 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"scripts": {
"watch": "yarn workspaces foreach -Api run watch",
"build": "yarn workspaces foreach -At run build",
"test": "yarn workspaces foreach -At run test",
"cli": "yarn workspace ipmc-tools run cli"
},
"workspaces": [
Expand Down
6 changes: 4 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"packageManager": "[email protected]",
"scripts": {
"watch": "tsc --watch",
"build": "tsc"
"build": "tsc",
"test": "vitest run"
},
"dependencies": {
"inversify": "^6.0.2",
Expand All @@ -14,6 +15,7 @@
"reflect-metadata": "^0.2.2"
},
"devDependencies": {
"typescript": "^5.4.5"
"typescript": "^5.4.5",
"vitest": "^2.1.8"
}
}
4 changes: 2 additions & 2 deletions packages/core/src/Regexes.ts
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)$/,
}
};
32 changes: 32 additions & 0 deletions packages/core/test/Regexes.test.ts
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();
});
});
2 changes: 1 addition & 1 deletion packages/tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
"@types/cli-progress": "^3.11.5",
"@types/fluent-ffmpeg": "^2.1.24",
"@types/yargs": "^17.0.32",
"vite-node": "^1.6.0"
"vite-node": "^2.1.8"
}
}
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"vite": "^5.2.11",
"vite-plugin-checker": "^0.6.4",
"vite-plugin-dts": "^3.9.1",
"vitest": "^1.6.0"
"vitest": "^2.1.8"
},
"dependencies": {
"@emotion/react": "^11.11.4",
Expand Down
Loading

0 comments on commit f5632fb

Please sign in to comment.