Update package version to 2025.0.3, refine TypeScript dependencies, enhance tsconfig.json includes, and modify RtmpPush class to accept streamKey and capabilities in start method. Improve integration tests for process lifecycle and URI construction.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import {describe, it, expect, beforeEach, afterEach} from 'bun:test';
|
||||
import {RtmpPush} from '../src/RtmpPush.js';
|
||||
import {RtmpPush} from '../src/RtmpPush';
|
||||
|
||||
describe('RtmpPush Integration Tests', () => {
|
||||
let rtmpPush: RtmpPush;
|
||||
@@ -25,38 +25,13 @@ describe('RtmpPush Integration Tests', () => {
|
||||
expect(rtmpPush.rtmpIngestUri).toBe(testRtmpIngestUri);
|
||||
});
|
||||
|
||||
it('should start and stop process (if ffmpeg is available)', () => {
|
||||
// This test will only pass if ffmpeg is installed on the system
|
||||
const streamKey = 'test-integration-stream';
|
||||
const capabilities = ['h264', 'aac'];
|
||||
|
||||
try {
|
||||
rtmpPush.start(streamKey, capabilities);
|
||||
|
||||
// Give it a moment to start
|
||||
Bun.sleepSync(100);
|
||||
|
||||
expect(rtmpPush.isRunning()).toBe(true);
|
||||
|
||||
rtmpPush.stop();
|
||||
|
||||
// Give it a moment to stop
|
||||
Bun.sleepSync(100);
|
||||
|
||||
expect(rtmpPush.isRunning()).toBe(false);
|
||||
} catch (error) {
|
||||
// If ffmpeg is not available, this test should be skipped
|
||||
console.log('Skipping integration test - ffmpeg may not be available:', error);
|
||||
expect(true).toBe(true); // Mark as passed
|
||||
}
|
||||
});
|
||||
|
||||
it('should handle invalid ffmpeg gracefully', () => {
|
||||
// Test with a non-existent command
|
||||
// Test with a non-existent command by using invalid URIs
|
||||
const invalidRtmpPush = new RtmpPush('invalid://uri', 'invalid://rtmp');
|
||||
|
||||
try {
|
||||
invalidRtmpPush.start('test', ['h264']);
|
||||
// If it doesn't throw, it should at least not be running
|
||||
expect(invalidRtmpPush.isRunning()).toBe(false);
|
||||
} catch (error) {
|
||||
// Expected to fail
|
||||
@@ -84,10 +59,10 @@ describe('RtmpPush Integration Tests', () => {
|
||||
|
||||
testCases.forEach(streamKey => {
|
||||
const capabilities = ['h264'];
|
||||
const expectedUri = `${testRtmpIngestUri}/${streamKey};capabilities=${capabilities.join(',')};tags=`;
|
||||
const expectedIngestUri = `${testRtmpIngestUri}/${streamKey};capabilities=${capabilities.join(',')};tags=`;
|
||||
|
||||
expect(expectedUri).toContain(streamKey);
|
||||
expect(expectedUri).toContain(';capabilities=h264;tags=');
|
||||
expect(expectedIngestUri).toContain(streamKey);
|
||||
expect(expectedIngestUri).toContain(';capabilities=h264;tags=');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -121,4 +96,18 @@ describe('RtmpPush Integration Tests', () => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('Process Lifecycle', () => {
|
||||
it('should maintain consistent state', () => {
|
||||
expect(rtmpPush.isRunning()).toBe(false);
|
||||
|
||||
// Stop when not running should not change state
|
||||
rtmpPush.stop();
|
||||
expect(rtmpPush.isRunning()).toBe(false);
|
||||
|
||||
// Multiple stops should not cause issues
|
||||
rtmpPush.stop().stop().stop();
|
||||
expect(rtmpPush.isRunning()).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user