forked from FallingSnow/h265ize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
87 lines (81 loc) · 2.88 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
const assert = require('chai').assert;
const h265ize = require('./h265ize');
const testVideoPath = 'test/sintel-test.mkv';
const nullFunc = function() {
return undefined;
}
const nullLogger = {
debug: nullFunc,
verbose: nullFunc,
info: nullFunc,
error: nullFunc,
alert: nullFunc,
warn: nullFunc
}
let Encoder, Video;
describe('Encoder', function() {
this.timeout(1000);
it('should return an instance of Encoder', function() {
assert.instanceOf(Encoder = new h265ize.Encoder(nullLogger), h265ize.Encoder, 'new h265ize.Encoder() did not return an instance of h265ize.Encoder');
});
it('should add a video by path', function() {
assert.includeDeepMembers(Encoder.queue, [Encoder.addVideo(testVideoPath)], 'video not added');
});
it('should start', function() {
assert.ifError(Encoder.start());
assert.isTrue(Encoder.running, 'encoder did not start');
});
it('should pause', function() {
assert.ifError(Encoder.pause());
assert.isTrue(Encoder.paused, 'encoder did not pause');
});
it('should resume', function() {
assert.ifError(Encoder.resume());
assert.isFalse(Encoder.paused, 'encoder is still paused');
});
it('should stop', function() {
assert.ifError(Encoder.stop());
assert.isFalse(Encoder.running, 'encoder is still running');
});
});
describe('Video', function() {
this.timeout(1000);
it('should return an instance of Video', function() {
assert.doesNotThrow(function() {
return new h265ize.Video(testVideoPath);
}, "Error while initializing h265ize.Video");
assert.instanceOf(Video = new h265ize.Video(testVideoPath), h265ize.Video, 'new h265ize.Encoder() is not an instance of h265ize.Encoder');
});
it('should add video to encoder', function() {
Encoder.addVideo(Video);
assert.includeDeepMembers(Encoder.queue, [Video], 'video not added');
});
it('should start', function() {
assert.ifError(Video.start());
assert.isTrue(Video.running, 'video did not start');
});
it('should pause', function() {
assert.ifError(Video.pause());
assert.isTrue(Video.paused, 'video did not pause');
});
it('should resume', function() {
assert.ifError(Video.resume());
assert.isFalse(Video.paused, 'video is still paused');
});
it('should stop', function() {
assert.ifError(Video.stop());
assert.isFalse(Video.running, 'video is still running');
});
it('should encode a video', function() {
let options = {
};
function handler() {
assert.isTrue(Video.status === 'finished');
}
Video = new h265ize.Video(testVideoPath, options)
.on('finished', handler)
.on('failed', handler);
});
it('should replace original video', function() {
});
});