Skip to content

Commit

Permalink
[test] add stubs and unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stephantabor committed Oct 13, 2015
1 parent ca0843c commit f10d267
Show file tree
Hide file tree
Showing 8 changed files with 359 additions and 125 deletions.
4 changes: 2 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ gulp.task('pre-test', function () {
gulp.task('test', ['pre-test'], function (cb) {
var mochaErr;

gulp.src('test/**/*.js')
gulp.src(['test/unit.js', 'test/integration.js'])
.pipe(plumber())
.pipe(mocha({reporter: 'spec'}))
.pipe(mocha({reporter: 'nyan'}))
.on('error', function (err) {
mochaErr = err;
})
Expand Down
7 changes: 4 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import Promise from 'bluebird';
import {extend, urlJoin} from './utils.js';

class Pkmn {
constructor() {
constructor(di) {
this.baseUrl = 'http://pokeapi.co';
this.queryUrl = urlJoin(this.baseUrl, 'api/v1');
this.request = di || request;
}

static listResources() {
Expand Down Expand Up @@ -34,7 +35,7 @@ class Pkmn {
return this.resource(resource);
}
if (/pokedex/.test(resource)) {
return this.resource('/api/v1/pokedex/1/');
return this.resource('/api/v1/pokedex/1');
}
if (id === undefined) {
return this.buildQuery(resource);
Expand All @@ -58,7 +59,7 @@ class Pkmn {

end(query) {
return new Promise((resolve, reject) => {
request
this.request
.get(query, (err, res, body) => {
if (res.statusCode !== 200) {
let e = new Error(res.statusCode);
Expand Down
114 changes: 0 additions & 114 deletions npm-debug.log

This file was deleted.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pkmn",
"version": "1.0.4",
"version": "1.0.5",
"description": "a node.js pokeapi.co api wrapper",
"homepage": "",
"repository": "stephantabor/pkmn",
Expand Down Expand Up @@ -31,7 +31,9 @@
"gulp-mocha": "^2.0.0",
"gulp-nsp": "^0.4.5",
"gulp-plumber": "^1.0.0",
"isparta": "^3.0.3"
"isparta": "^3.0.3",
"rewire": "^2.3.4",
"sinon": "^1.17.1"
},
"scripts": {
"prepublish": "gulp prepublish",
Expand Down
Loading

0 comments on commit f10d267

Please sign in to comment.