generated from homebridge/homebridge-plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enable speaker creation using name as alternative to id
- Loading branch information
Showing
9 changed files
with
146 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
setupFiles: ['dotenv/config'], | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { API, Logger, PlatformConfig } from 'homebridge'; | ||
import { SpotifyApiWrapper } from './spotify-api-wrapper'; | ||
|
||
it('should authenticate and persist tokens', async () => { | ||
// given | ||
const wrapper = new SpotifyApiWrapper( | ||
console as Logger, | ||
{ | ||
spotifyAuthCode: process.env.SPOTIFY_AUTH_CODE!, | ||
spotifyClientId: process.env.SPOTIFY_CLIENT_ID!, | ||
spotifyClientSecret: process.env.SPOTIFY_CLIENT_SECRET!, | ||
} as unknown as PlatformConfig, | ||
{ user: { persistPath: () => '.' } } as API, | ||
); | ||
|
||
// when | ||
const result = await wrapper.authenticate(); | ||
wrapper.persistTokens(); | ||
|
||
// then | ||
expect(result).toBe(true); | ||
}); | ||
|
||
it('should retrieve device list', async () => { | ||
// given | ||
const wrapper = new SpotifyApiWrapper( | ||
console as Logger, | ||
{ | ||
spotifyAuthCode: process.env.SPOTIFY_AUTH_CODE!, | ||
spotifyClientId: process.env.SPOTIFY_CLIENT_ID!, | ||
spotifyClientSecret: process.env.SPOTIFY_CLIENT_SECRET!, | ||
} as unknown as PlatformConfig, | ||
{ user: { persistPath: () => '.' } } as API, | ||
); | ||
|
||
// when | ||
await wrapper.authenticate(); | ||
const devices = await wrapper.getMyDevices(); | ||
|
||
// then | ||
expect(devices?.length).toBeGreaterThan(0); | ||
}); | ||
|
||
it('should retrieve playback state', async () => { | ||
// given | ||
const wrapper = new SpotifyApiWrapper( | ||
console as Logger, | ||
{ | ||
spotifyAuthCode: process.env.SPOTIFY_AUTH_CODE!, | ||
spotifyClientId: process.env.SPOTIFY_CLIENT_ID!, | ||
spotifyClientSecret: process.env.SPOTIFY_CLIENT_SECRET!, | ||
} as unknown as PlatformConfig, | ||
{ user: { persistPath: () => '.' } } as API, | ||
); | ||
|
||
// when | ||
await wrapper.authenticate(); | ||
const state = await wrapper.getPlaybackState(); | ||
|
||
// then | ||
expect(state?.statusCode).toEqual(200); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters