forked from helgeholm/vtt-adjust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscale.spec.js
59 lines (53 loc) · 2.3 KB
/
scale.spec.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
var adjust = require('../lib/adjust');
var read = require('../lib/readSegments');
var write = require('../lib/writeSegments');
var fs = require('fs');
var assert = require('assert');
describe("move and scale", function() {
it("changes nothing if references are unchanged", function() {
var input = fs.readFileSync("test/data/simple.vtt").toString();
var data = read(input);
adjust.moveAndScale(data.cues, data.cues[0], data.cues[1]);
assert.equal(write(data), input);
});
it("can scale and not move", function() {
var input = fs.readFileSync("test/data/simpler.vtt").toString();
var output = fs.readFileSync("test/data/simpler-scaleup.vtt").toString();
var data = read(input);
var cue3 = JSON.parse(JSON.stringify(data.cues[2]));
cue3.start += 20000;
adjust.moveAndScale(data.cues, data.cues[0], cue3);
assert.equal(write(data), output);
});
it("can scale down and not move", function() {
var input = fs.readFileSync("test/data/simpler.vtt").toString();
var output = fs.readFileSync("test/data/simpler-scaledown.vtt").toString();
var data = read(input);
var cue3 = JSON.parse(JSON.stringify(data.cues[2]));
cue3.start -= 10000;
adjust.moveAndScale(data.cues, data.cues[0], cue3);
assert.equal(write(data), output);
});
it("can scale and move into simpler+10s-scaleup result", function() {
var input = fs.readFileSync("test/data/simpler.vtt").toString();
var output = fs.readFileSync("test/data/simpler+10s-scaleup.vtt").toString();
var data = read(input);
var cue1 = JSON.parse(JSON.stringify(data.cues[0]));
cue1.start = 20*1000;
var cue3 = JSON.parse(JSON.stringify(data.cues[2]));
cue3.start = 3*60*1000;
adjust.moveAndScale(data.cues, cue1, cue3);
assert.equal(write(data), output);
});
it("can scale and move into simpler+10s-scaleup result, different ref", function() {
var input = fs.readFileSync("test/data/simpler.vtt").toString();
var output = fs.readFileSync("test/data/simpler+10s-scaleup.vtt").toString();
var data = read(input);
var cue1 = JSON.parse(JSON.stringify(data.cues[0]));
cue1.start = 20*1000;
var cue2 = JSON.parse(JSON.stringify(data.cues[1]));
cue2.start = 100*1000;
adjust.moveAndScale(data.cues, cue1, cue2);
assert.equal(write(data), output);
});
});