|
1 | 1 | 'use strict'; |
2 | 2 |
|
3 | | -var test = require('tape'); //jshint ignore:line |
4 | | -var Github = require("../"); |
| 3 | +// module dependencies |
| 4 | +var chai = require('chai'), sinonChai = require('sinon-chai'); |
| 5 | + |
| 6 | +var Github = require('../'); |
5 | 7 | var test_user = require('./user.json'); |
6 | 8 |
|
7 | | -test("User API", function(t) { |
8 | | - var timeout = setTimeout(function () { t.fail(); }, 100000); |
9 | | - var github = new Github({ |
10 | | - username: test_user.USERNAME, |
11 | | - password: test_user.PASSWORD, |
12 | | - auth: "basic" |
13 | | - }); |
14 | | - // var user = github.getUser(); |
| 9 | +// Use should flavour for Mocha |
| 10 | +var should = chai.should(); |
| 11 | +chai.use(sinonChai); |
15 | 12 |
|
| 13 | +describe('Github.Search', function() { |
| 14 | + var github = new Github({ |
| 15 | + username: test_user.USERNAME, |
| 16 | + password: test_user.PASSWORD, |
| 17 | + auth: "basic" |
| 18 | + }); |
16 | 19 |
|
17 | | - t.test('Search.repositories', function(q) { |
18 | | - var search = github.getSearch("tetris+language:assembly&sort=stars&order=desc"); |
19 | | - var options = null; |
| 20 | + it('should search.repositories', function(done) { |
| 21 | + var search = github.getSearch('tetris+language:assembly&sort=stars&order=desc'); |
| 22 | + var options = null; |
20 | 23 |
|
21 | | - search.repositories(options, function (err) { |
22 | | - q.error(err, 'search repositories'); |
23 | | - q.end(); |
24 | | - }); |
| 24 | + search.repositories(options, function (err) { |
| 25 | + should.not.exist(err); |
| 26 | + done(); |
25 | 27 | }); |
| 28 | + }); |
26 | 29 |
|
27 | | - t.test('Search.code', function(q) { |
28 | | - var search = github.getSearch("addClass+in:file+language:js+repo:jquery/jquery"); |
29 | | - var options = null; |
| 30 | + it('should search.code', function(done) { |
| 31 | + var search = github.getSearch('addClass+in:file+language:js+repo:jquery/jquery'); |
| 32 | + var options = null; |
30 | 33 |
|
31 | | - search.code(options, function (err) { |
32 | | - q.error(err, 'search code'); |
33 | | - q.end(); |
34 | | - }); |
| 34 | + search.code(options, function (err) { |
| 35 | + should.not.exist(err); |
| 36 | + done(); |
35 | 37 | }); |
| 38 | + }); |
36 | 39 |
|
37 | | - t.test('Search.issues', function(q) { |
38 | | - var search = github.getSearch("windows+label:bug+language:python+state:open&sort=created&order=asc"); |
39 | | - var options = null; |
| 40 | + it('should search.issues', function(done) { |
| 41 | + var search = github.getSearch('windows+label:bug+language:python+state:open&sort=created&order=asc'); |
| 42 | + var options = null; |
40 | 43 |
|
41 | | - search.issues(options, function (err) { |
42 | | - q.error(err, 'search issues'); |
43 | | - q.end(); |
44 | | - }); |
| 44 | + search.issues(options, function (err) { |
| 45 | + should.not.exist(err); |
| 46 | + done(); |
45 | 47 | }); |
| 48 | + }); |
46 | 49 |
|
47 | | - t.test('Search.users', function(q) { |
48 | | - var search = github.getSearch("tom+repos:%3E42+followers:%3E1000"); |
49 | | - var options = null; |
| 50 | + it('should search.users', function(done) { |
| 51 | + var search = github.getSearch('tom+repos:%3E42+followers:%3E1000'); |
| 52 | + var options = null; |
50 | 53 |
|
51 | | - search.users(options, function (err) { |
52 | | - q.error(err, 'search users'); |
53 | | - q.end(); |
54 | | - }); |
| 54 | + search.users(options, function (err) { |
| 55 | + should.not.exist(err); |
| 56 | + done(); |
55 | 57 | }); |
56 | | - |
57 | | - |
58 | | - |
59 | | - clearTimeout(timeout); |
60 | | - t.end(); |
61 | | - }); |
| 58 | + }); |
| 59 | +}); |
0 commit comments