Skip to content

Commit

Permalink
Add new tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mugan86 committed Jan 3, 2019
1 parent 356d1e2 commit 400be42
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
37 changes: 37 additions & 0 deletions test/error403.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const obtenerUsuario = require('./../index').obtenerDatosDeUsuario;

const expect = require('chai').expect;

var nock = require('nock');

const error403 = require('./respuestas/403');

describe('Test de datos de diferentes usuarios de Github', () => {
beforeEach(() => {
nock('https://api.github.com')
.log(console.log)
.get('/users/mugan86').
reply(403, error403);
});
it('Error 403 demasiadas request en un intervalo corto', () => {
return obtenerUsuario('mugan86').then(
respuesta => {
// Probar el tipo de variable que obtenemos de repsuesta. Tiene que ser un objeto.
expect(typeof respuesta).to.equal('object');

// Comprobar que el usuario de la API es mugan86
expect(respuesta.message).to.equal('API rate limit exceeded for 83.213.183.48. (But here\'s the good news: Authenticated requests get a higher rate limit. Checkout the documentation for more details.)');
// Documentation URL
expect(respuesta.documentation_url).to.equal('https://developer.github.com/v3/#rate-limiting');
// Message is string
expect(typeof respuesta.message).to.equal('string');
// URL documentation string
expect(typeof respuesta.documentation_url).to.equal('string');

}
)
});
afterEach(() => {
nock = null;
});
});
4 changes: 4 additions & 0 deletions test/respuestas/403.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
message: 'API rate limit exceeded for 83.213.183.48. (But here\'s the good news: Authenticated requests get a higher rate limit. Checkout the documentation for more details.)',
documentation_url: 'https://developer.github.com/v3/#rate-limiting'
};
1 change: 0 additions & 1 deletion test/respuestas/mugan86.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module.exports = {

"login": "mugan86",
"id": 5081970,
"node_id": "MDQ6VXNlcjUwODE5NzA=",
Expand Down

0 comments on commit 400be42

Please sign in to comment.