Add unit tests for spotify
This commit is contained in:
parent
493482386e
commit
f6907766bd
4 changed files with 48 additions and 12 deletions
|
@ -39,6 +39,6 @@ module.exports.parseUrl = function(url, next) {
|
||||||
var matches = parse(url).path.match(/\/album[\/]+([^\/]+)/);
|
var matches = parse(url).path.match(/\/album[\/]+([^\/]+)/);
|
||||||
|
|
||||||
if (matches && matches[1]) {
|
if (matches && matches[1]) {
|
||||||
return next({id:matches[1], type: "album"})
|
next({id:matches[1], type: "album"})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,5 +21,8 @@
|
||||||
"rdio": "^1.5.2",
|
"rdio": "^1.5.2",
|
||||||
"serve-favicon": "~2.1.3",
|
"serve-favicon": "~2.1.3",
|
||||||
"spotify": "^0.3.0"
|
"spotify": "^0.3.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"should": "^4.3.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
32
test/test.js
Normal file
32
test/test.js
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
var assert = require("assert");
|
||||||
|
var should = require('should');
|
||||||
|
var spotify = require("../lib/spotify");
|
||||||
|
|
||||||
|
describe('Spotify', function(){
|
||||||
|
describe('lookupId', function(){
|
||||||
|
it('should find album by ID', function(done){
|
||||||
|
spotify.lookupId("77UW17CZFyCaRLHdHeofZu", "album", function(result) {
|
||||||
|
result.name.should.equal("Listen (Deluxe)");
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('search', function(){
|
||||||
|
it('should find album by search', function(done){
|
||||||
|
spotify.search("David Guetta Listen (Deluxe)", "album", function(result) {
|
||||||
|
result.name.should.equal("Listen (Deluxe)");
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('parseUrl', function(){
|
||||||
|
it('should parse url into ID', function(done){
|
||||||
|
spotify.parseUrl("https://play.spotify.com/album/77UW17CZFyCaRLHdHeofZu", function(result) {
|
||||||
|
result.id.should.equal("77UW17CZFyCaRLHdHeofZu");
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -12,22 +12,23 @@
|
||||||
.container {
|
.container {
|
||||||
padding-top: 100px;
|
padding-top: 100px;
|
||||||
}
|
}
|
||||||
.url-search {
|
.form-inline {
|
||||||
text-align: center;
|
padding-bottom: 100px;
|
||||||
padding-bottom: 50px;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row url-search">
|
<div class="row">
|
||||||
<%= error %>
|
<div class="col-sm-6 col-sm-offset-3">
|
||||||
<form role="form" method="post" action="/search" class="form-inline">
|
<%= error %>
|
||||||
<div class="form-group form-group-lg">
|
<form role="form" method="post" action="/search" class="form-inline">
|
||||||
<input type="text" name="url" placeholder="Paste link here" class="form-control">
|
<div class="form-group form-group-lg">
|
||||||
<input type="submit" class="btn btn-default btn-lg" value="Share Music">
|
<input type="text" name="url" placeholder="Paste link here" class="form-control">
|
||||||
</div>
|
<input type="submit" class="btn btn-default btn-lg" value="Share Music">
|
||||||
</form>
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-6 col-sm-offset-3">
|
<div class="col-sm-6 col-sm-offset-3">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue