-
Notifications
You must be signed in to change notification settings - Fork 31
/
test.js
121 lines (111 loc) · 4.06 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
var expect = require('chai').expect;
require('blanket'); // eslint-disable-line import/no-unassigned-import
var logSymbols = require('log-symbols');
var chalk = require('chalk');
var itunesRemote = require('./');
describe('itunesRemote', function () {
it('should throw an error when called without command', function () {
expect(itunesRemote).to.throw(Error, /You have to call itunesRemote with a command/);
});
describe('command `play`', function () {
it('should return »✔ Playing ♪♬«', function (done) {
itunesRemote('play', function (response) {
expect(response).to.equal(logSymbols.success + ' Playing ♪♬');
done();
});
});
});
describe('command `stop`', function () {
it('should return »✔ Stopped playing ♪♬«', function (done) {
itunesRemote('stop', function (response) {
expect(response).to.equal(logSymbols.success + ' Stopped playing ♪♬');
done();
});
});
});
describe('command `pause`', function () {
it('should return »✔ Paused playing ♪♬«', function (done) {
itunesRemote('pause', function (response) {
expect(response).to.equal(logSymbols.success + ' Paused playing ♪♬');
done();
});
});
});
describe('command `next`', function () {
it('should return »✔ Skipped track.«', function (done) {
itunesRemote('next', function (response) {
expect(response).to.equal(logSymbols.success + ' Skipped track.');
done();
});
});
});
describe('command `previous`', function () {
it('should return »✔ Returned to previous track.«', function (done) {
itunesRemote('previous', function (response) {
expect(response).to.equal(logSymbols.success + ' Returned to previous track.');
done();
});
});
});
describe('command `back`', function () {
it('should return »✔ Returned to previous track or beginning of current track.«', function (done) {
itunesRemote('back', function (response) {
expect(response).to.equal(logSymbols.success + ' Returned to previous track or beginning of current track.');
done();
});
});
});
describe('command `search`', function () {
this.timeout(15000);
it('should return success message', function (done) {
this.timeout(15000);
setTimeout(done, 15000);
itunesRemote('search', function (response) {
expect(response).to.equal(logSymbols.success + ' Found songs by ”' +
chalk.inverse('emancipator') + '“ and generated a temporary playlist');
done();
}, {searchterm: 'emancipator', options: {dontplay: true, artists: true}}
);
});
it('should return error message when no search results for all', function (done) {
itunesRemote('search', function (response) {
expect(response).to.equal(logSymbols.error + ' Oops. Found 0 songs, albums and artists containing ”' +
chalk.inverse('foozel') + '“.');
done();
}, {searchterm: 'foozel', options: {}}
);
});
it('should return error message when no search results for albums', function (done) {
itunesRemote('search', function (response) {
expect(response).to.equal(logSymbols.error + ' Oops. Found 0 album containing ”' +
chalk.inverse('foozel') + '“.');
done();
}, {searchterm: 'foozel', options: {albums: true}}
);
});
it('should return error message when no search results for songs', function (done) {
itunesRemote('search', function (response) {
expect(response).to.equal(logSymbols.error + ' Oops. Found 0 songs containing ”' +
chalk.inverse('foozel') + '“.');
done();
}, {searchterm: 'foozel', options: {songs: true}}
);
});
it('should return error message when no search results for artists', function (done) {
itunesRemote('search', function (response) {
expect(response).to.equal(logSymbols.error + ' Oops. Found 0 songs by ”' +
chalk.inverse('foozel') + '“.');
done();
}, {searchterm: 'foozel', options: {artists: true}}
);
});
});
describe('command `getData`', function () {
it('should return an object.', function (done) {
itunesRemote('getData', function (response) {
expect(response).to.be.an('object');
done();
});
});
});
});