@quatrain/worker 1.2.7 → 1.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const Helpers_1 = require("./Helpers");
4
+ const Worker_1 = require("./Worker");
5
+ jest.mock('./Worker', () => {
6
+ const original = jest.requireActual('./Worker');
7
+ return {
8
+ Worker: {
9
+ ...original.Worker,
10
+ getSystemCommandPath: jest.fn().mockResolvedValue('/usr/bin/ffmpeg'),
11
+ execPromise: jest.fn().mockResolvedValue(true),
12
+ info: jest.fn(),
13
+ }
14
+ };
15
+ });
16
+ describe('Helpers', () => {
17
+ beforeEach(() => {
18
+ jest.clearAllMocks();
19
+ });
20
+ it('should generate video thumbnail parameters correctly and execute ffmpeg', async () => {
21
+ const videoPath = 'test.mp4';
22
+ const outputPath = 'output.jpg';
23
+ const result = await Helpers_1.Helpers.generateVideoThumbnail(videoPath, outputPath, 5, 640);
24
+ expect(result).toBe(true);
25
+ expect(Worker_1.Worker.execPromise).toHaveBeenCalledWith('/usr/bin/ffmpeg', [
26
+ '-i',
27
+ 'test.mp4',
28
+ '-vframes',
29
+ '1',
30
+ '-vf',
31
+ 'select=gte(n\\,5)',
32
+ '-s',
33
+ '640x480',
34
+ '-ss',
35
+ '1',
36
+ 'output.jpg',
37
+ '-y'
38
+ ]);
39
+ });
40
+ it('should use default values for frame and width', async () => {
41
+ const videoPath = 'test.mp4';
42
+ const outputPath = 'output.jpg';
43
+ const result = await Helpers_1.Helpers.generateVideoThumbnail(videoPath, outputPath);
44
+ expect(result).toBe(true);
45
+ expect(Worker_1.Worker.execPromise).toHaveBeenCalledWith('/usr/bin/ffmpeg', [
46
+ '-i',
47
+ 'test.mp4',
48
+ '-vframes',
49
+ '1',
50
+ '-vf',
51
+ 'select=gte(n\\,0)',
52
+ '-s',
53
+ '320x240',
54
+ '-ss',
55
+ '1',
56
+ 'output.jpg',
57
+ '-y'
58
+ ]);
59
+ });
60
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quatrain/worker",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "description": "Container Worker helpers",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,66 @@
1
+ import { Helpers } from './Helpers'
2
+ import { Worker } from './Worker'
3
+
4
+ jest.mock('./Worker', () => {
5
+ const original = jest.requireActual('./Worker')
6
+ return {
7
+ Worker: {
8
+ ...original.Worker,
9
+ getSystemCommandPath: jest.fn().mockResolvedValue('/usr/bin/ffmpeg'),
10
+ execPromise: jest.fn().mockResolvedValue(true),
11
+ info: jest.fn(),
12
+ }
13
+ }
14
+ })
15
+
16
+ describe('Helpers', () => {
17
+ beforeEach(() => {
18
+ jest.clearAllMocks()
19
+ })
20
+
21
+ it('should generate video thumbnail parameters correctly and execute ffmpeg', async () => {
22
+ const videoPath = 'test.mp4'
23
+ const outputPath = 'output.jpg'
24
+
25
+ const result = await Helpers.generateVideoThumbnail(videoPath, outputPath, 5, 640)
26
+
27
+ expect(result).toBe(true)
28
+ expect(Worker.execPromise).toHaveBeenCalledWith('/usr/bin/ffmpeg', [
29
+ '-i',
30
+ 'test.mp4',
31
+ '-vframes',
32
+ '1',
33
+ '-vf',
34
+ 'select=gte(n\\,5)',
35
+ '-s',
36
+ '640x480',
37
+ '-ss',
38
+ '1',
39
+ 'output.jpg',
40
+ '-y'
41
+ ])
42
+ })
43
+
44
+ it('should use default values for frame and width', async () => {
45
+ const videoPath = 'test.mp4'
46
+ const outputPath = 'output.jpg'
47
+
48
+ const result = await Helpers.generateVideoThumbnail(videoPath, outputPath)
49
+
50
+ expect(result).toBe(true)
51
+ expect(Worker.execPromise).toHaveBeenCalledWith('/usr/bin/ffmpeg', [
52
+ '-i',
53
+ 'test.mp4',
54
+ '-vframes',
55
+ '1',
56
+ '-vf',
57
+ 'select=gte(n\\,0)',
58
+ '-s',
59
+ '320x240',
60
+ '-ss',
61
+ '1',
62
+ 'output.jpg',
63
+ '-y'
64
+ ])
65
+ })
66
+ })