forked from KKBOX/OpenAPI-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsdktest.js.html
More file actions
224 lines (199 loc) · 11.6 KB
/
Copy pathsdktest.js.html
File metadata and controls
224 lines (199 loc) · 11.6 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<base data-ice="baseUrl" href="../../../">
<title data-ice="title">src/test/sdktest.js | @kkbox/kkbox-js-sdk</title>
<link type="text/css" rel="stylesheet" href="css/style.css">
<link type="text/css" rel="stylesheet" href="css/prettify-tomorrow.css">
<script src="script/prettify/prettify.js"></script>
<script src="script/manual.js"></script>
<meta name="description" content="KKBOX Open API Developer SDK for JavaScript"><meta property="twitter:card" content="summary"><meta property="twitter:title" content="@kkbox/kkbox-js-sdk"><meta property="twitter:description" content="KKBOX Open API Developer SDK for JavaScript"></head>
<body class="layout-container" data-ice="rootContainer">
<header>
<a href="./">Home</a>
<a href="identifiers.html">Reference</a>
<a href="source.html">Source</a>
<div class="search-box">
<span>
<img src="./image/search.png">
<span class="search-input-edge"></span><input class="search-input"><span class="search-input-edge"></span>
</span>
<ul class="search-result"></ul>
</div>
<a style="position:relative; top:3px;" href="https://github.com/KKBOX/OpenAPI-JavaScript"><img width="20px" src="./image/github.png"></a></header>
<nav class="navigation" data-ice="nav"><div>
<ul>
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#api">api</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/api/AlbumFetcher.js~AlbumFetcher.html">AlbumFetcher</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/api/Api.js~Api.html">Api</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/api/ArtistFetcher.js~ArtistFetcher.html">ArtistFetcher</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/api/ChartFetcher.js~ChartFetcher.html">ChartFetcher</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/api/FeaturedPlaylistCategoryFetcher.js~FeaturedPlaylistCategoryFetcher.html">FeaturedPlaylistCategoryFetcher</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/api/FeaturedPlaylistFetcher.js~FeaturedPlaylistFetcher.html">FeaturedPlaylistFetcher</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/api/Fetcher.js~Fetcher.html">Fetcher</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/api/GenreStationFetcher.js~GenreStationFetcher.html">GenreStationFetcher</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/api/HttpClient.js~HttpClient.html">HttpClient</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/api/MoodStationFetcher.js~MoodStationFetcher.html">MoodStationFetcher</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/api/NewHitsPlaylistFetcher.js~NewHitsPlaylistFetcher.html">NewHitsPlaylistFetcher</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/api/NewReleaseCategoryFetcher.js~NewReleaseCategoryFetcher.html">NewReleaseCategoryFetcher</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/api/SearchFetcher.js~SearchFetcher.html">SearchFetcher</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/api/SharedPlaylistFetcher.js~SharedPlaylistFetcher.html">SharedPlaylistFetcher</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/api/TrackFetcher.js~TrackFetcher.html">TrackFetcher</a></span></span></li>
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#auth">auth</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/auth/Auth.js~Auth.html">Auth</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/auth/ClientCredentialsFlow.js~ClientCredentialsFlow.html">ClientCredentialsFlow</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/auth/TokenFetcher.js~TokenFetcher.html">TokenFetcher</a></span></span></li>
</ul>
</div>
</nav>
<div class="content" data-ice="content"><h1 data-ice="title">src/test/sdktest.js</h1>
<pre class="source-code line-number raw-source-code"><code class="prettyprint linenums" data-ice="content">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));
});
});
});
});
});
});
});
</code></pre>
</div>
<footer class="footer">
Generated by <a href="https://esdoc.org">ESDoc<span data-ice="esdocVersion">(1.1.0)</span><img src="./image/esdoc-logo-mini-black.png"></a>
</footer>
<script src="script/search_index.js"></script>
<script src="script/search.js"></script>
<script src="script/pretty-print.js"></script>
<script src="script/inherited-summary.js"></script>
<script src="script/test-summary.js"></script>
<script src="script/inner-link.js"></script>
<script src="script/patch-for-local.js"></script>
</body>
</html>