Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tasadurian committed Feb 7, 2016
1 parent eb11a7a commit df945e8
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
15 changes: 15 additions & 0 deletions .travis.yml
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
30 changes: 30 additions & 0 deletions index.js
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;
33 changes: 33 additions & 0 deletions package.json
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"
}
}
24 changes: 24 additions & 0 deletions test/test.js
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");
});
});
});

0 comments on commit df945e8

Please sign in to comment.