/
users.js
99 lines (82 loc) · 2.36 KB
/
users.js
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
var Testrail = require('../index');
var expect = require('chai').expect;
var nock = require('nock');
describe('users api', function() {
var testrail = new Testrail({
host: 'https://rundef.testrail.com',
user: 'username',
password: 'password'
});
nock('https://rundef.testrail.com')
.get(testrail.uri + 'get_user/1')
.reply(200, {
'email': 'alexis@example.com',
'id': 1,
'is_active': true,
'name': 'Alexis Gonzalez'
});
nock('https://rundef.testrail.com')
.get(testrail.uri + 'get_user/2')
.reply(400, {
error: 'Field :user is not a valid user.'
});
nock('https://rundef.testrail.com')
.get(testrail.uri + 'get_user_by_email&email='+encodeURIComponent('alexis@example.com'))
.reply(200, {
'email': 'alexis@example.com',
'id': 1,
'is_active': true,
'name': 'Alexis Gonzalez'
});
nock('https://rundef.testrail.com')
.get(testrail.uri + 'get_users')
.reply(200, [
{ 'id': 1, 'name': 'Alexis Gonzalez' },
{ 'id': 2, 'name': 'Ciaran Davenport' }
]);
nock('https://rundef.testrail.com')
.get(testrail.uri + 'get_users/10')
.reply(200, [
{ 'id': 1, 'name': 'Alexis Gonzalez' },
]);
it('Get one', function (done) {
testrail.getUser(1, function (err, response, body) {
expect(err).to.be.null;
expect(response).to.be.an.object;
expect(body).to.be.an.object;
done();
});
});
it('Get one - not found', function (done) {
testrail.getUser(2, function (err, response, body) {
expect(err).to.not.be.null;
expect(response).to.be.an.object;
expect(body).to.be.an.object;
done();
});
});
it('Get one by email', function (done) {
testrail.getUserByEmail('alexis@example.com', function (err, response, body) {
expect(err).to.be.null;
expect(response).to.be.an.object;
expect(body).to.be.an.object;
done();
});
});
it('Get all', function (done) {
testrail.getUsers(function (err, response, body) {
expect(err).to.be.null;
expect(response).to.be.an.object;
expect(body).to.be.an.array;
done();
});
});
it('Get all by project', function (done) {
testrail.getUsers(10, function (err, response, body) {
expect(err).to.be.null;
expect(response).to.be.an.object;
expect(body).to.be.an.array;
done();
});
});
});