1 | import Flash from '../src/plugin';
|
2 | import QUnit from 'qunit';
|
3 |
|
4 | QUnit.module('Flash RTMP');
|
5 |
|
6 | const streamToPartsAndBack = function(url) {
|
7 | const parts = Flash.streamToParts(url);
|
8 |
|
9 | return Flash.streamFromParts(parts.connection, parts.stream);
|
10 | };
|
11 |
|
12 | QUnit.test('test using both streamToParts and streamFromParts', function(assert) {
|
13 | assert.ok(streamToPartsAndBack('rtmp://myurl.com/isthis') === 'rtmp://myurl.com/&isthis');
|
14 | assert.ok(streamToPartsAndBack('rtmp://myurl.com/&isthis') === 'rtmp://myurl.com/&isthis');
|
15 | assert.ok(streamToPartsAndBack('rtmp://myurl.com/isthis/andthis') === 'rtmp://myurl.com/isthis/&andthis');
|
16 | });
|
17 |
|
18 | QUnit.test('test streamToParts', function(assert) {
|
19 | let parts = Flash.streamToParts('http://myurl.com/streaming&/is/fun');
|
20 |
|
21 | assert.ok(parts.connection === 'http://myurl.com/streaming');
|
22 | assert.ok(parts.stream === '/is/fun');
|
23 |
|
24 | parts = Flash.streamToParts('http://myurl.com/&streaming&/is/fun');
|
25 | assert.ok(parts.connection === 'http://myurl.com/');
|
26 | assert.ok(parts.stream === 'streaming&/is/fun');
|
27 |
|
28 | parts = Flash.streamToParts('http://myurl.com/really?streaming=fun&really=fun');
|
29 | assert.ok(parts.connection === 'http://myurl.com/');
|
30 | assert.ok(parts.stream === 'really?streaming=fun&really=fun');
|
31 |
|
32 | parts = Flash.streamToParts('http://myurl.com/streaming/is/fun');
|
33 | assert.ok(parts.connection === 'http://myurl.com/streaming/is/');
|
34 | assert.ok(parts.stream === 'fun');
|
35 |
|
36 | parts = Flash.streamToParts('whatisgoingonhere');
|
37 | assert.ok(parts.connection === 'whatisgoingonhere');
|
38 | assert.ok(parts.stream === '');
|
39 |
|
40 | parts = Flash.streamToParts();
|
41 | assert.ok(parts.connection === '');
|
42 | assert.ok(parts.stream === '');
|
43 | });
|
44 |
|
45 | QUnit.test('test isStreamingSrc', function(assert) {
|
46 | const isStreamingSrc = Flash.isStreamingSrc;
|
47 |
|
48 | assert.ok(isStreamingSrc('rtmp://streaming.is/fun'));
|
49 | assert.ok(isStreamingSrc('rtmps://streaming.is/fun'));
|
50 | assert.ok(isStreamingSrc('rtmpe://streaming.is/fun'));
|
51 | assert.ok(isStreamingSrc('rtmpt://streaming.is/fun'));
|
52 |
|
53 | assert.ok(!isStreamingSrc('rtmp:streaming.is/fun'));
|
54 | assert.ok(!isStreamingSrc('rtmpz://streaming.is/fun'));
|
55 | assert.ok(!isStreamingSrc('http://streaming.is/fun'));
|
56 | assert.ok(!isStreamingSrc('https://streaming.is/fun'));
|
57 | assert.ok(!isStreamingSrc('file://streaming.is/fun'));
|
58 | });
|