-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eb11a7a
commit df945e8
Showing
5 changed files
with
103 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/ |
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,15 @@ | ||
language: node_js | ||
node_js: | ||
- "4.1" | ||
- "4.0" | ||
- "0.12" | ||
- "0.11" | ||
- "iojs" | ||
|
||
# The following are currently not supported: | ||
# - "0.10" | ||
# - "0.8" | ||
# - "0.6" | ||
|
||
notifications: | ||
email: false |
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,30 @@ | ||
var rp = require('request-promise'); | ||
|
||
var pokeUrl = 'http://pokeapi.co'; | ||
|
||
getJSON = function(url) { | ||
var options = { | ||
url: url, | ||
json: true, | ||
}; | ||
return rp.get(options) | ||
.catch(function(error) { | ||
return error; | ||
}) | ||
.then(function(response) { | ||
return response; | ||
}); | ||
}; | ||
|
||
var Pokedex = (function() { | ||
function Pokedex() {} | ||
|
||
Pokedex.prototype.getBerryByName = function(name) { | ||
return getJSON(pokeUrl + '/api/v2/berry/' + name); | ||
}; | ||
|
||
|
||
return Pokedex; | ||
})(); | ||
|
||
module.exports = Pokedex; |
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,33 @@ | ||
{ | ||
"name": "pokedex-promise-v2", | ||
"version": "1.0.0", | ||
"description": "A small library used to get information about specific pokemon.", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "mocha" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/TheTommyTwitch/pokedex-promise-v2.git" | ||
}, | ||
"keywords": [ | ||
"pokedex", | ||
"pokemon", | ||
"nintendo", | ||
"promise" | ||
], | ||
"author": "Thomas Asadurian <[email protected]> (http://thetommytwitch.github.io/)", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/TheTommyTwitch/pokedex-promise-v2/issues" | ||
}, | ||
"homepage": "https://github.com/TheTommyTwitch/pokedex-promise-v2#readme", | ||
"dependencies": { | ||
"chai": "^3.5.0", | ||
"chai-as-promised": "^5.2.0", | ||
"chai-things": "^0.2.0", | ||
"mocha": "^2.4.5", | ||
"request": "^2.65.0", | ||
"request-promise": "^2.0.0" | ||
} | ||
} |
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,24 @@ | ||
var Pokedex = require("../index.js"); | ||
var chai = require('chai'), | ||
expect = chai.expect; | ||
|
||
chai.use(require("chai-as-promised")); | ||
chai.use(require("chai-things")); | ||
|
||
describe("pokedex", function() { | ||
var promise, | ||
id = 5, | ||
P = new Pokedex(); | ||
|
||
describe(".getBerryByName(Id: int)", function() { | ||
before(function() { | ||
promise = P.getBerryByName(id); | ||
}); | ||
it("should succeed", function() { | ||
return promise; | ||
}); | ||
it("should have property name", function() { | ||
return expect(promise).to.eventually.have.property("name"); | ||
}); | ||
}); | ||
}); |