-
-
Notifications
You must be signed in to change notification settings - Fork 430
/
Copy pathtime.test.js
62 lines (39 loc) · 1.66 KB
/
time.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
const Amplitude = require("../../src/index.js");
const config = require("../../src/config.js");
const Setup = require("../setup.js");
const Time = require("../../src/utilities/time.js");
beforeEach(() => {
Setup.initializeTestingElement();
Setup.initializeAmplitude();
});
afterEach(() => {
Setup.resetConfig();
});
test("AmplitudeJS Time Utility Produces Correct Current Time", () => {
var currentTime = Time.computeCurrentTimes();
expect(currentTime).toEqual({ seconds: "30", minutes: "00", hours: "00" });
config.audio.currentTime = 120;
currentTime = Time.computeCurrentTimes();
expect(currentTime).toEqual({ seconds: "00", minutes: "02", hours: "00" });
config.audio.currentTime = 3605;
currentTime = Time.computeCurrentTimes();
expect(currentTime).toEqual({ seconds: "05", minutes: "00", hours: 1 });
});
test("AmplitudeJS Time Utility Produces Correct Duration Time", () => {
var duration = Time.computeSongDuration();
expect(duration).toEqual({ seconds: "40", minutes: "01", hours: "00" });
config.audio.duration = 245;
duration = Time.computeSongDuration();
expect(duration).toEqual({ seconds: "05", minutes: "04", hours: "00" });
config.audio.duration = 3605;
duration = Time.computeSongDuration();
expect(duration).toEqual({ seconds: "05", minutes: "00", hours: "1" });
});
test("AmplitudeJS Time Utility Produces Correct Song Completion Percentage", () => {
var songCompletionPercentage = Time.computeSongCompletionPercentage();
expect(songCompletionPercentage).toBe(30);
});
test("AmplitudeJS Time Utility Sets The Correct Current Time", () => {
Time.setCurrentTime(68);
expect(config.audio.currentTime).toBe(68);
});