RepoApiTest.js
1.83 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
53
54
55
56
57
58
59
60
61
62
/**
* 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 sys = require("sys");
var GitHubApi = require("../lib/github").GitHubApi;
var async_testing = require('../vendor/node-async-testing/async_testing');
var suite = exports.suite = new async_testing.TestSuite();
suite.setup(function() {
this.github = new GitHubApi(true);
this.repoApi = this.github.getRepoApi();
});
suite.addTests({
"test: search repos" : function(assert, finished, test) {
test.repoApi.search("php github api", function(err, repos) {
assert.ok(repos.length > 0);
assert.ok(repos[0].name !== undefined);
finished();
});
},
"test: show repository" : function(assert, finished, test) {
test.repoApi.show("fjakobs", "qxoo", function(err, repo) {
assert.equal(repo.name, "qxoo");
finished();
});
},
"test: get user repos" : function(assert, finished, test) {
test.repoApi.getUserRepos("fjakobs", function(err, repos) {
assert.ok(repos.length > 0);
assert.ok(repos[0].name !== undefined);
finished();
});
},
"test: get repo tags" : function(assert, finished, test) {
test.repoApi.getRepoTags("fjakobs", "node", function(err, tags) {
assert.ok(tags["v0.1.0"] == "813b53938b40484f63e7324c030e33711f26a149");
finished();
});
},
"test: get repo branches" : function(assert, finished, test) {
test.repoApi.getRepoBranches("fjakobs", "node", function(err, branches) {
assert.ok(branches["master"] !== undefined);
finished();
});
}
});
if (module === require.main) {
async_testing.runSuites({RepoApi: suite});
}