Skip to content

Commit

Permalink
chore: add more test cases to scanning logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Dec 8, 2023
1 parent 03f1de9 commit 7016caf
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"scripts": {
"dev": "nodemon ./src",
"build": "run build:ts && node tools/build.mjs",
"build:ts": "rimraf dist && tsc -b",
"build:ts": "rimraf dist && tsc -b tsconfig.build.json",
"build-linux-arm64": "node tools/build.mjs linux arm64",
"build-linux-x64": "node tools/build.mjs linux x64",
"build-win32-x64": "node tools/build.mjs win32 x64",
Expand Down
54 changes: 51 additions & 3 deletions src/__tests__/ffmpeg.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const targetVersions = require('./ffmpegReleases.json')

const testMediaPath = path.join(__dirname, 'samples')

function runForFFmpegRelease(ffprobePath: string, ffmpegPath: string) {
function runForFFmpegRelease(ffprobePath: string, ffmpegPath: string, _ffmpegVersion: string) {
function createBareDoc(filename: string): PouchDBMediaDocument {
return {
_id: 'test',
Expand All @@ -27,11 +27,58 @@ function runForFFmpegRelease(ffprobePath: string, ffmpegPath: string) {
},
}

test('png', async () => {
test('grey.png', async () => {
const doc = createBareDoc('grey.png')
await generateInfo(defaultConfig, doc)
expect(doc.cinf).toBe('"GREY" STILL 45678 20231206123456 0 0/1\r\n')
})
test('Still_Gif.gif', async () => {
const doc = createBareDoc('Still_Gif.gif')
await generateInfo(defaultConfig, doc)
expect(doc.cinf).toBe('"STILL_GIF" STILL 45678 20231206123456 0 0/1\r\n')
})
test('Still_Jpeg.jpg', async () => {
const doc = createBareDoc('Still_Jpeg.jpg')
await generateInfo(defaultConfig, doc)
expect(doc.cinf).toBe('"STILL_JPEG" STILL 45678 20231206123456 0 0/1\r\n')
})
test('ExtractedStill.mov', async () => {
const doc = createBareDoc('ExtractedStill.mov')
await generateInfo(defaultConfig, doc)
expect(doc.cinf).toBe('"EXTRACTEDSTILL" STILL 45678 20231206123456 0 0/1\r\n')
})

test('AudioOnly.mp3', async () => {
const doc = createBareDoc('AudioOnly.mp3')
await generateInfo(defaultConfig, doc)
expect(doc.cinf).toBe('"AUDIOONLY" AUDIO 45678 20231206123456 28788480 1/14112000\r\n')
})
test('audio_with_poster.mp3', async () => {
const doc = createBareDoc('audio_with_poster.mp3')
await generateInfo(defaultConfig, doc)
expect(doc.cinf).toBe('"AUDIO_WITH_POSTER" AUDIO 45678 20231206123456 28788480 1/14112000\r\n')
})

test('Movie_a0v1.mov', async () => {
const doc = createBareDoc('Movie_a0v1.mov')
await generateInfo(defaultConfig, doc)
expect(doc.cinf).toBe('"MOVIE_A0V1" MOVIE 45678 20231206123456 50 1/25\r\n')
})
test('Movie_v0a1.mov', async () => {
const doc = createBareDoc('Movie_v0a1.mov')
await generateInfo(defaultConfig, doc)
expect(doc.cinf).toBe('"MOVIE_V0A1" MOVIE 45678 20231206123456 50 1/25\r\n')
})
test('Mute_Video.mov', async () => {
const doc = createBareDoc('Mute_Video.mov')
await generateInfo(defaultConfig, doc)
expect(doc.cinf).toBe('"MUTE_VIDEO" MOVIE 45678 20231206123456 50 1/25\r\n')
})
test('MXF_OP1a.mxf', async () => {
const doc = createBareDoc('MXF_OP1a.mxf')
await generateInfo(defaultConfig, doc)
expect(doc.cinf).toBe('"MXF_OP1A" MOVIE 45678 20231206123456 50 1/25\r\n')
})
}

const ffprobeFilename = process.platform === 'win32' ? 'bin/ffprobe.exe' : 'ffprobe'
Expand All @@ -42,7 +89,8 @@ for (const version of targetVersions[`${process.platform}-${process.arch}`]) {
describe(`FFmpeg ${version.id}`, () => {
runForFFmpegRelease(
path.join(ffmpegRootPath, version.id, ffprobeFilename),
path.join(ffmpegRootPath, version.id, ffmpegFilename)
path.join(ffmpegRootPath, version.id, ffmpegFilename),
version.id
)
})
}
Binary file added src/__tests__/samples/AudioOnly.mp3
Binary file not shown.
Binary file added src/__tests__/samples/ExtractedStill.mov
Binary file not shown.
Binary file added src/__tests__/samples/MXF_OP1a.mxf
Binary file not shown.
Binary file added src/__tests__/samples/Movie_a0v1.mov
Binary file not shown.
Binary file added src/__tests__/samples/Movie_v0a1.mov
Binary file not shown.
Binary file added src/__tests__/samples/Mute_Video.mov
Binary file not shown.
Binary file added src/__tests__/samples/Still_Gif.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/__tests__/samples/Still_Jpeg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/__tests__/samples/audio_with_poster.mp3
Binary file not shown.

0 comments on commit 7016caf

Please sign in to comment.