forked from github-tools/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.auth.js
More file actions
44 lines (37 loc) · 1.07 KB
/
test.auth.js
File metadata and controls
44 lines (37 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
'use strict';
var Github = require('../src/github.js');
var testUser = require('./user.json');
var github, user;
describe('Github constructor', function() {
before(function() {
github = new Github({
username: testUser.USERNAME,
password: testUser.PASSWORD,
auth: 'basic'
});
user = github.getUser();
});
it('should authenticate and return no errors', function(done) {
user.notifications(function(err) {
should.not.exist(err);
done();
});
});
});
describe('Github constructor (failing case)', function() {
before(function() {
github = new Github({
username: testUser.USERNAME,
password: 'fake124',
auth: 'basic'
});
user = github.getUser();
});
it('should fail authentication and return err', function(done) {
user.notifications(function(err) {
err.error.should.equal(401, 'Return 401 status for bad auth');
JSON.parse(err.request.responseText).message.should.equal('Bad credentials');
done();
});
});
});