forked from rauchg/slackin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslack-invite.js
44 lines (38 loc) · 983 Bytes
/
slack-invite.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
import nock from 'nock';
import assert from 'assert';
import invite from '../lib/slack-invite';
describe('slack-invite', () => {
describe('.invite()', () => {
var opts;
before(() => {
opts = {
channel: 'mychannel',
email: '[email protected]',
org: 'myorg',
token: 'mytoken'
};
});
it("succeeds when ok", (done) => {
nock(`https://${opts.org}.slack.com`).
post('/api/users.admin.invite').
reply(200, { ok: true });
invite(opts, (err) => {
assert.equal(err, null);
done();
});
});
it("passes along an error message", (done) => {
nock(`https://${opts.org}.slack.com`).
post('/api/users.admin.invite').
reply(200, {
ok: false,
error: "other error"
});
invite(opts, (err) => {
assert.notEqual(err, null);
assert.equal(err.message, "other error");
done();
});
});
});
});