forked from riazXrazor/vtt-to-srt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
57 lines (30 loc) · 1.04 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"use strict";
var tape = require('tape');
var vtt2srt = require('./');
var concat = require('concat-stream');
tape('empty', function(t) {
var convert = vtt2srt();
convert.end();
convert.pipe(concat(function(data) {
t.same(data.toString(), '');
t.end();
}));
});
tape('one entry', function(t) {
var convert = vtt2srt();
convert.write('WEBVTT FILE\r\n\r\n00:00:10.500 --> 00:00:13.000\r\nthis is a test\r\n\r\n');
convert.end();
convert.pipe(concat(function(data) {
t.same(data.toString(), '1\r\n00:00:10,500 --> 00:00:13,000\r\nthis is a test\r\n');
t.end();
}));
});
tape('two entries', function(t) {
var convert = vtt2srt();
convert.write('WEBVTT FILE\r\n\r\n00:00:10.500 --> 00:00:13.000\r\nthis is a test\r\n00:00:14.500 --> 00:00:15.000\r\nthis is a test\r\n\r\n');
convert.end();
convert.pipe(concat(function(data) {
t.same(data.toString(), '1\r\n00:00:10,500 --> 00:00:13,000\r\nthis is a test\r\n\r\n2\r\n00:00:14,500 --> 00:00:15,000\r\nthis is a test\r\n');
t.end();
}));
});