1
0
mirror of https://github.com/videojs/video.js.git synced 2024-12-14 11:23:30 +02:00
video.js/test/unit/tech/flash-rtmp.test.js
2016-08-12 13:51:31 -04:00

59 lines
2.3 KiB
JavaScript

/* eslint-env qunit */
import Flash from '../../../src/js/tech/flash.js';
QUnit.module('Flash RTMP');
const streamToPartsAndBack = function(url) {
const parts = Flash.streamToParts(url);
return Flash.streamFromParts(parts.connection, parts.stream);
};
QUnit.test('test using both streamToParts and streamFromParts', function(assert) {
assert.ok(streamToPartsAndBack('rtmp://myurl.com/isthis') === 'rtmp://myurl.com/&isthis');
assert.ok(streamToPartsAndBack('rtmp://myurl.com/&isthis') === 'rtmp://myurl.com/&isthis');
assert.ok(streamToPartsAndBack('rtmp://myurl.com/isthis/andthis') === 'rtmp://myurl.com/isthis/&andthis');
});
QUnit.test('test streamToParts', function(assert) {
let parts = Flash.streamToParts('http://myurl.com/streaming&/is/fun');
assert.ok(parts.connection === 'http://myurl.com/streaming');
assert.ok(parts.stream === '/is/fun');
parts = Flash.streamToParts('http://myurl.com/&streaming&/is/fun');
assert.ok(parts.connection === 'http://myurl.com/');
assert.ok(parts.stream === 'streaming&/is/fun');
parts = Flash.streamToParts('http://myurl.com/really?streaming=fun&really=fun');
assert.ok(parts.connection === 'http://myurl.com/');
assert.ok(parts.stream === 'really?streaming=fun&really=fun');
parts = Flash.streamToParts('http://myurl.com/streaming/is/fun');
assert.ok(parts.connection === 'http://myurl.com/streaming/is/');
assert.ok(parts.stream === 'fun');
parts = Flash.streamToParts('whatisgoingonhere');
assert.ok(parts.connection === 'whatisgoingonhere');
assert.ok(parts.stream === '');
parts = Flash.streamToParts();
assert.ok(parts.connection === '');
assert.ok(parts.stream === '');
});
QUnit.test('test isStreamingSrc', function(assert) {
const isStreamingSrc = Flash.isStreamingSrc;
assert.ok(isStreamingSrc('rtmp://streaming.is/fun'));
assert.ok(isStreamingSrc('rtmps://streaming.is/fun'));
assert.ok(isStreamingSrc('rtmpe://streaming.is/fun'));
assert.ok(isStreamingSrc('rtmpt://streaming.is/fun'));
// test invalid protocols
assert.ok(!isStreamingSrc('rtmp:streaming.is/fun'));
assert.ok(!isStreamingSrc('rtmpz://streaming.is/fun'));
assert.ok(!isStreamingSrc('http://streaming.is/fun'));
assert.ok(!isStreamingSrc('https://streaming.is/fun'));
assert.ok(!isStreamingSrc('file://streaming.is/fun'));
});