-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding a util to convert spotify links to uris
- Loading branch information
chrisdevwords
authored and
chrisdevwords
committed
Aug 13, 2017
1 parent
d7c2b09
commit 56b32f6
Showing
3 changed files
with
41 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const {describe, it} = require('mocha'); | ||
const { expect, config } = require('chai'); | ||
const { convertLinkToUri } = require('../../src/spotify'); | ||
|
||
|
||
const context = describe; | ||
|
||
config.includeStack = true; | ||
|
||
describe('#spotify.convertLinkToUri', () => { | ||
|
||
context('with an http link to a spotify track', () => { | ||
it('converts it to a uri', () => { | ||
const link = 'https://open.spotify.com/track/5uSXPDwXLpYF7aLmTnB3Mb'; | ||
const uri = convertLinkToUri(link); | ||
expect(uri).to.equal('spotify:track:5uSXPDwXLpYF7aLmTnB3Mb'); | ||
}); | ||
}); | ||
|
||
context('with a uri to a spotify track', () => { | ||
it('returns the uri as is', () => { | ||
const link = 'spotify:track:5uSXPDwXLpYF7aLmTnB3Mb'; | ||
const uri = convertLinkToUri(link); | ||
expect(uri).to.equal('spotify:track:5uSXPDwXLpYF7aLmTnB3Mb'); | ||
}); | ||
}); | ||
|
||
context('with a string that is not a spotify link', () => { | ||
it('doesn\'t break', () => { | ||
const link = 'https://developer.spotify.com/web-api/get-track/'; | ||
const uri = convertLinkToUri(link); | ||
expect(uri).to.be.a('String'); | ||
}); | ||
}); | ||
}); |
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