cody-music
Advanced tools
Comparing version 2.6.5 to 2.6.6
@@ -14,4 +14,4 @@ "use strict"; | ||
const models_1 = require("../../lib/models"); | ||
const profile_1 = require("../../lib/profile"); | ||
const userProfile = profile_1.UserProfile.getInstance(); | ||
const util_2 = require("../../lib/util"); | ||
const musicUtil = new util_2.MusicUtil(); | ||
const testUtil = new util_1.TestUtil(); | ||
@@ -39,15 +39,47 @@ /** | ||
after("clean up spotify nonplaylist testing", done => { | ||
done(); | ||
CodyMusic.getSpotifyDevices().then(async (response) => { | ||
if (response && response.length > 0) { | ||
// get the 1st device id | ||
const device_id = response[0].id; | ||
const options = { | ||
device_id | ||
}; | ||
response = await CodyMusic.pause(CodyMusic.PlayerName.SpotifyWeb, options); | ||
done(); | ||
} | ||
else { | ||
done(); | ||
} | ||
}); | ||
}); | ||
it("return songs not in a playlist", done => { | ||
CodyMusic.getSavedTracks(models_1.PlayerName.SpotifyWeb, { limit: 50 }) | ||
.then(result => { | ||
expect(result.length).to.not.equal(0); | ||
done(); | ||
}) | ||
.catch(err => { | ||
console.log("error getting saved tracks: ", err.message); | ||
CodyMusic.getSpotifyDevices().then(devices => { | ||
CodyMusic.getSavedTracks(models_1.PlayerName.SpotifyWeb, { limit: 50 }) | ||
.then(result => { | ||
expect(result.length).to.not.equal(0); | ||
if (devices && devices.length > 0) { | ||
const track = result[0]; | ||
const track_id = track.uri; | ||
const device = devices[0]; | ||
const options = { | ||
device_id: device.id, | ||
track_ids: [track_id] | ||
}; | ||
// play this track | ||
CodyMusic.play(CodyMusic.PlayerName.SpotifyWeb, options).then(result => { | ||
musicUtil.sleep(3000); | ||
expect(result.status).to.equal(204); | ||
done(); | ||
}); | ||
} | ||
else { | ||
done(); | ||
} | ||
}) | ||
.catch(err => { | ||
console.log("error getting saved tracks: ", err.message); | ||
}); | ||
}); | ||
}); | ||
it("return the tracks of a playlist", done => { | ||
xit("return the tracks of a playlist", done => { | ||
CodyMusic.getPlaylists(models_1.PlayerName.SpotifyWeb).then(result => { | ||
@@ -61,4 +93,3 @@ let playlist_id = result[0].id; | ||
}); | ||
it("return a spotify track by id", done => { | ||
// spotify:track:4iVVU8DyQvOVsKafv3KWIF | ||
xit("return a spotify track by id", done => { | ||
CodyMusic.getSpotifyTrackById("spotify:track:4iVVU8DyQvOVsKafv3KWIF", true) | ||
@@ -65,0 +96,0 @@ .then((track) => { |
{ | ||
"name": "cody-music", | ||
"version": "2.6.5", | ||
"version": "2.6.6", | ||
"description": "mac osx spotify and itunes music player controller, spotify audio features, itunes and spotify genre, and playlist control", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
const expect = require("chai").expect; | ||
import * as CodyMusic from "../../index"; | ||
import { TestUtil } from "../util"; | ||
import { PlayerName, PlaylistItem, Track, Album } from "../../lib/models"; | ||
import { UserProfile, SpotifyUser } from "../../lib/profile"; | ||
import { PlayerName, Track, PlayerDevice, TrackStatus } from "../../lib/models"; | ||
import { MusicUtil } from "../../lib/util"; | ||
const userProfile = UserProfile.getInstance(); | ||
const musicUtil = new MusicUtil(); | ||
const testUtil = new TestUtil(); | ||
@@ -34,17 +33,53 @@ | ||
after("clean up spotify nonplaylist testing", done => { | ||
done(); | ||
CodyMusic.getSpotifyDevices().then(async (response: any) => { | ||
if (response && response.length > 0) { | ||
// get the 1st device id | ||
const device_id = response[0].id; | ||
const options = { | ||
device_id | ||
}; | ||
response = await CodyMusic.pause( | ||
CodyMusic.PlayerName.SpotifyWeb, | ||
options | ||
); | ||
done(); | ||
} else { | ||
done(); | ||
} | ||
}); | ||
}); | ||
it("return songs not in a playlist", done => { | ||
CodyMusic.getSavedTracks(PlayerName.SpotifyWeb, { limit: 50 }) | ||
.then(result => { | ||
expect(result.length).to.not.equal(0); | ||
done(); | ||
}) | ||
.catch(err => { | ||
console.log("error getting saved tracks: ", err.message); | ||
}); | ||
CodyMusic.getSpotifyDevices().then(devices => { | ||
CodyMusic.getSavedTracks(PlayerName.SpotifyWeb, { limit: 50 }) | ||
.then(result => { | ||
expect(result.length).to.not.equal(0); | ||
if (devices && devices.length > 0) { | ||
const track: Track = result[0]; | ||
const track_id = track.uri; | ||
const device: PlayerDevice = devices[0]; | ||
const options = { | ||
device_id: device.id, | ||
track_ids: [track_id] | ||
}; | ||
// play this track | ||
CodyMusic.play( | ||
CodyMusic.PlayerName.SpotifyWeb, | ||
options | ||
).then(result => { | ||
musicUtil.sleep(3000); | ||
expect(result.status).to.equal(204); | ||
done(); | ||
}); | ||
} else { | ||
done(); | ||
} | ||
}) | ||
.catch(err => { | ||
console.log("error getting saved tracks: ", err.message); | ||
}); | ||
}); | ||
}); | ||
it("return the tracks of a playlist", done => { | ||
xit("return the tracks of a playlist", done => { | ||
CodyMusic.getPlaylists(PlayerName.SpotifyWeb).then(result => { | ||
@@ -62,4 +97,3 @@ let playlist_id = result[0].id; | ||
it("return a spotify track by id", done => { | ||
// spotify:track:4iVVU8DyQvOVsKafv3KWIF | ||
xit("return a spotify track by id", done => { | ||
CodyMusic.getSpotifyTrackById( | ||
@@ -66,0 +100,0 @@ "spotify:track:4iVVU8DyQvOVsKafv3KWIF", |
398967
9731