-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
3 changed files
with
41 additions
and
1 deletion.
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,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; | ||
}); | ||
}); |
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,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' | ||
}; |
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
module.exports = { | ||
|
||
"login": "mugan86", | ||
"id": 5081970, | ||
"node_id": "MDQ6VXNlcjUwODE5NzA=", | ||
|