@kkbox/kkbox-js-sdk
Version:
KKBOX Open API developer SDK for JavaScript. Use it to easily access KKBOX open API to get various metadata about KKBOX's tracks, albums, artists, playlists and stations.
134 lines (129 loc) • 5.85 kB
JavaScript
;
var _should = _interopRequireDefault(require("should"));
var _ = require("../");
var _client_secrets = require("../../client_secrets.json");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var CLIENT_ID = _client_secrets.kkbox_sdk.client_id;
var CLIENT_SECRET = _client_secrets.kkbox_sdk.client_secret;
describe('SDK Begin to Test', function () {
describe('Auth', function () {
it('should get access token', function () {
var auth = new _.Auth(CLIENT_ID, CLIENT_SECRET);
return auth.clientCredentialsFlow.fetchAccessToken().then(function (response) {
describe('Api With Fake Token', function () {
var api = new _.Api('FAKE_TOKEN', 'HK');
describe('Property checking', function () {
it('should have HK as territory', function (done) {
api.territory.should.be.exactly('HK');
done();
});
});
describe('Search with fake token', function () {
it('should fail', function () {
return api.searchFetcher.setSearchCriteria('flash').fetchSearchResult().then(function (response) {
_should["default"].not.exists(response);
})["catch"](function (error) {
_should["default"].exists(error);
});
});
});
});
var access_token = response.data.access_token;
access_token.should.be.ok;
describe('Api', function () {
var api = new _.Api('FAKE_TOKEN', 'HK');
api.setToken(access_token);
describe('Search', function () {
it('should response status 200', function () {
return api.searchFetcher.setSearchCriteria('flash').fetchSearchResult().then(function (response) {
return response.status.should.be.exactly(200);
});
});
});
describe('Track', function () {
it('should response status 200', function () {
return api.trackFetcher.setTrackID('KpnEGVHEsGgkoB0MBk').fetchMetadata().then(function (response) {
return response.status.should.be.exactly(200);
});
});
});
describe('Album', function () {
it('should response status 200', function () {
return api.albumFetcher.setAlbumID('KmRKnW5qmUrTnGRuxF').fetchMetadata().then(function (response) {
return response.status.should.be.exactly(200);
});
});
});
describe('Artist', function () {
it('should response status 200', function () {
return api.artistFetcher.setArtistID('Cnv_K6i5Ft4y41SxLy').fetchMetadata().then(function (response) {
return response.status.should.be.exactly(200);
});
});
});
describe('Featured Playlists', function () {
it('should response status 200', function () {
return api.featuredPlaylistFetcher.fetchAllFeaturedPlaylists().then(function (response) {
return response.status.should.be.exactly(200);
});
});
});
describe('Featured Playlist Category', function () {
it('should response status 200', function () {
return api.featuredPlaylistCategoryFetcher.fetchAllFeaturedPlaylistCategories().then(function (response) {
return response.status.should.be.exactly(200);
});
});
});
describe('Mood Station', function () {
it('should response status 200', function () {
return api.moodStationFetcher.fetchAllMoodStations().then(function (response) {
return response.status.should.be.exactly(200);
});
});
});
describe('Genre Station', function () {
it('should response status 200', function () {
return api.genreStationFetcher.fetchAllGenreStations().then(function (response) {
return response.status.should.be.exactly(200);
});
});
});
describe('Chart', function () {
it('should response status 200', function () {
return api.chartFetcher.fetchCharts().then(function (response) {
return response.status.should.be.exactly(200);
});
});
});
describe('New Release Category', function () {
it('should response status 200', function () {
return api.newReleaseCategoryFetcher.fetchAllNewReleaseCategories().then(function (response) {
return response.status.should.be.exactly(200);
});
});
});
describe('New Hits Playlists', function () {
it('should response status 200', function () {
return api.newHitsPlaylistFetcher.fetchAllNewHitsPlaylists().then(function (response) {
return response.status.should.be.exactly(200);
});
});
});
describe('Shared Playlist', function () {
it('should response status 200', function () {
return api.sharedPlaylistFetcher.setPlaylistID('KsOjSf4whgbL45hRfl').fetchMetadata().then(function (response) {
return response.status.should.be.exactly(200);
});
});
it('should response status 200', function () {
return api.sharedPlaylistFetcher.setPlaylistID('KsOjSf4whgbL45hRfl').fetchTracks().then(function (response) {
return response.status.should.be.exactly(200);
});
});
});
});
});
});
});
});