AuthentificationTest.js
1.48 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
45
46
47
48
49
50
51
52
/**
* Copyright 2010 Ajax.org B.V.
*
* This product includes software developed by
* Ajax.org B.V. (http://www.ajax.org/).
*
* Author: Fabian Jaokbs <fabian@ajax.org>
*/
var GitHubApi = require("../lib/github").GitHubApi;
var async_testing = require('../vendor/node-async-testing/async_testing');
var suite = exports.suite = new async_testing.TestSuite();
var username = 'fjakobstest';
var token = 'b98166e45acf66df70a992e2de56b92a';
var repo = "o3";
suite.setup(function() {
this.github = new GitHubApi(true);
this.userApi = this.github.getUserApi();
});
suite.addTests({
"test: show user without authentification should have no 'plan'" : function(assert, finished, test) {
test.userApi.show(username, function(err, user) {
assert.equal(user.plan, undefined);
finished();
});
},
"test: show user with authentification should have a 'plan'" : function(assert, finished, test) {
test.github.authenticate(username, token);
test.userApi.show(username, function(err, user) {
assert.ok(user.plan !== undefined);
finished();
});
},
"test: authenticate with bad token" : function(assert, finished, test) {
test.github.authenticate(username, "bad-token");
test.userApi.show(username, function(err, user) {
assert.ok(err !== undefined);
finished();
});
}
});
if (module === require.main) {
async_testing.runSuites({GitHubApi: suite});
}