-
Notifications
You must be signed in to change notification settings - Fork 800
Expand file tree
/
Copy patherror.spec.js
More file actions
83 lines (70 loc) · 2.16 KB
/
error.spec.js
File metadata and controls
83 lines (70 loc) · 2.16 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import assert from 'assert';
import expect from 'must';
import nock from 'nock';
import Github from '../lib/GitHub';
import testUser from './fixtures/user.js';
import {assertSuccessful, assertFailure} from './helpers/callbacks';
import fixtureExhausted from './fixtures/repos-ratelimit-exhausted.js';
import fixtureOk from './fixtures/repos-ratelimit-ok.js';
describe('Rate limit error', function() {
let github;
let user;
let scope;
before(function() {
github = new Github();
user = github.getUser(testUser.USERNAME);
});
beforeEach(function() {
scope = fixtureExhausted();
});
it('should reject promise with 403 error', function() {
return user.listRepos().then(function() {
assert.fail(undefined, undefined, 'Promise was resolved instead of rejected');
}, function(error) {
expect(error).to.be.an.error();
expect(error).to.have.own('response');
expect(error.response).to.have.own('status');
expect(error.response.status).to.be(403);
});
});
it('should call callback', function(done) {
user.listRepos(assertFailure(done, function(error) {
expect(error).to.be.an.error();
expect(error).to.have.own('response');
expect(error.response).to.have.own('status');
expect(error.response.status).to.be(403);
done();
}));
});
afterEach(function() {
scope.done();
nock.cleanAll();
});
});
describe('Rate limit OK', function() {
let github;
let user;
let scope;
before(function() {
github = new Github();
user = github.getUser(testUser.USERNAME);
});
beforeEach(function() {
scope = fixtureOk();
});
it('should resolve promise', function() {
return expect(user.listRepos()).to.resolve.to.object();
});
it('should call callback with array of results', function(done) {
user.listRepos(assertSuccessful(done, function(error, result) {
expect(error).is.not.an.error();
expect(error).is.not.truthy();
expect(result).is.array();
done();
}));
});
afterEach(function() {
scope.done();
nock.cleanAll();
});
});