-
-
Notifications
You must be signed in to change notification settings - Fork 430
/
Copy pathshuffleElements.test.js
63 lines (50 loc) · 1.62 KB
/
shuffleElements.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
const Amplitude = require("../../src/index.js");
const config = require("../../src/config.js");
const Setup = require("../setup.js");
beforeEach(() => {
buildShuffleElements();
Setup.initializeTestingElement();
Setup.initializeAmplitude();
});
afterEach(() => {
Setup.resetConfig();
});
function buildShuffleElements() {
document.body.innerHTML =
'<div class="amplitude-shuffle" id="global-shuffle"></div>' +
'<div class="amplitude-shuffle" data-amplitude-playlist="trip_hop" id="playlist-shuffle"></div>';
}
test("AmplitudeJS Shuffles Songs Accordingly", () => {
document.getElementById("global-shuffle").click();
expect(
document
.getElementById("global-shuffle")
.classList.contains("amplitude-shuffle-on")
);
expect(config.shuffle_list.length).toBe(config.songs.length);
document.getElementById("global-shuffle").click();
expect(
document
.getElementById("global-shuffle")
.classList.contains("amplitude-shuffle-off")
);
expect(config.shuffle_list.length).toBe(0);
});
test("AmplitudeJS Shuffles Playlist Songs Accordingly", () => {
document.getElementById("playlist-shuffle").click();
expect(
document
.getElementById("playlist-shuffle")
.classList.contains("amplitude-shuffle-on")
);
expect(config.playlists["trip_hop"].shuffle_list.length).toBe(
config.playlists["trip_hop"].songs.length
);
document.getElementById("playlist-shuffle").click();
expect(
document
.getElementById("playlist-shuffle")
.classList.contains("amplitude-shuffle-off")
);
expect(config.playlists["trip_hop"].shuffle_list.length).toBe(0);
});