forked from KKBOX/OpenAPI-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsdktest.js
More file actions
153 lines (137 loc) · 5.29 KB
/
Copy pathsdktest.js
File metadata and controls
153 lines (137 loc) · 5.29 KB
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import should from 'should';
import { Auth, Api } from '../';
import { kkbox_sdk } from '../../client_secrets.json';
const CLIENT_ID = kkbox_sdk.client_id;
const CLIENT_SECRET = kkbox_sdk.client_secret;
describe('SDK Begin to Test', () => {
describe('Auth', () => {
it('should get access token', () => {
const auth = new Auth(CLIENT_ID, CLIENT_SECRET);
return auth.clientCredentialsFlow.fetchAccessToken().then(response => {
describe('Api With Fake Token', () => {
const api = new Api('FAKE_TOKEN', 'HK');
describe('Property checking', () => {
it('should have HK as territory', done => {
api.territory.should.be.exactly('HK');
done();
});
});
describe('Search with fake token', () => {
it('should fail', () => {
return api.searchFetcher
.setSearchCriteria('flash')
.fetchSearchResult()
.then(response => {
should.not.exists(response);
})
.catch(error => {
should.exists(error);
});
});
});
});
const access_token = response.data.access_token;
access_token.should.be.ok;
describe('Api', () => {
const api = new Api('FAKE_TOKEN', 'HK');
api.setToken(access_token);
describe('Search', () => {
it('should response status 200', () => {
return api.searchFetcher
.setSearchCriteria('flash')
.fetchSearchResult()
.then(response => response.status.should.be.exactly(200));
});
});
describe('Track', () => {
it('should response status 200', () => {
return api.trackFetcher
.setTrackID('KpnEGVHEsGgkoB0MBk')
.fetchMetadata()
.then(response => response.status.should.be.exactly(200));
});
});
describe('Album', () => {
it('should response status 200', () => {
return api.albumFetcher
.setAlbumID('KmRKnW5qmUrTnGRuxF')
.fetchMetadata()
.then(response => response.status.should.be.exactly(200));
});
});
describe('Artist', () => {
it('should response status 200', () => {
return api.artistFetcher
.setArtistID('Cnv_K6i5Ft4y41SxLy')
.fetchMetadata()
.then(response => response.status.should.be.exactly(200));
});
});
describe('Featured Playlists', () => {
it('should response status 200', () => {
return api.featuredPlaylistFetcher
.fetchAllFeaturedPlaylists()
.then(response => response.status.should.be.exactly(200));
});
});
describe('Featured Playlist Category', () => {
it('should response status 200', () => {
return api.featuredPlaylistCategoryFetcher
.fetchAllFeaturedPlaylistCategories()
.then(response => response.status.should.be.exactly(200));
});
});
describe('Mood Station', () => {
it('should response status 200', () => {
return api.moodStationFetcher
.fetchAllMoodStations()
.then(response => response.status.should.be.exactly(200));
});
});
describe('Genre Station', () => {
it('should response status 200', () => {
return api.genreStationFetcher
.fetchAllGenreStations()
.then(response => response.status.should.be.exactly(200));
});
});
describe('Chart', () => {
it('should response status 200', () => {
return api.chartFetcher
.fetchCharts()
.then(response => response.status.should.be.exactly(200));
});
});
describe('New Release Category', () => {
it('should response status 200', () => {
return api.newReleaseCategoryFetcher
.fetchAllNewReleaseCategories()
.then(response => response.status.should.be.exactly(200));
});
});
describe('New Hits Playlists', () => {
it('should response status 200', () => {
return api.newHitsPlaylistFetcher
.fetchAllNewHitsPlaylists()
.then(response => response.status.should.be.exactly(200));
});
});
describe('Shared Playlist', () => {
it('should response status 200', () => {
return api.sharedPlaylistFetcher
.setPlaylistID('KsOjSf4whgbL45hRfl')
.fetchMetadata()
.then(response => response.status.should.be.exactly(200));
});
it('should response status 200', () => {
return api.sharedPlaylistFetcher
.setPlaylistID('KsOjSf4whgbL45hRfl')
.fetchTracks()
.then(response => response.status.should.be.exactly(200));
});
});
});
});
});
});
});