|
| 1 | +import assert from 'assert'; |
| 2 | +import {Client} from '../lib'; |
| 3 | +var nock = require('nock'); |
| 4 | + |
| 5 | +describe('users', function () { |
| 6 | + it('should be created', function (done) { |
| 7 | + nock('https://api.intercom.io').post('/users', { email: '[email protected]' }).reply(200, {}); |
| 8 | + let client = new Client('foo', 'bar'); |
| 9 | + client.users.create({ email: '[email protected]' }, function (r) { |
| 10 | + assert.equal(200, r.status); |
| 11 | + done(); |
| 12 | + }); |
| 13 | + }); |
| 14 | + it('should list', function (done) { |
| 15 | + nock('https://api.intercom.io').get('/users').reply(200, {}); |
| 16 | + let client = new Client('foo', 'bar'); |
| 17 | + client.users.list(function (r) { |
| 18 | + assert.equal(200, r.status); |
| 19 | + done(); |
| 20 | + }); |
| 21 | + }); |
| 22 | + it('should list by params', function (done) { |
| 23 | + nock('https://api.intercom.io').get('/users').query({ tag_id: '1234' }).reply(200, {}); |
| 24 | + let client = new Client('foo', 'bar'); |
| 25 | + client.users.listBy({ tag_id: '1234' }, function (r) { |
| 26 | + assert.equal(200, r.status); |
| 27 | + done(); |
| 28 | + }); |
| 29 | + }); |
| 30 | + it('find users by id', function (done) { |
| 31 | + nock('https://api.intercom.io').get('/users/baz').reply(200, {}); |
| 32 | + let client = new Client('foo', 'bar'); |
| 33 | + client.users.find({ id: 'baz' }, function (r) { |
| 34 | + assert.equal(200, r.status); |
| 35 | + done(); |
| 36 | + }); |
| 37 | + }); |
| 38 | + it('deletes users by id', function (done) { |
| 39 | + nock('https://api.intercom.io').delete('/users/baz').reply(200, {}); |
| 40 | + let client = new Client('foo', 'bar'); |
| 41 | + client.users.delete({ id: 'baz' }, function (r) { |
| 42 | + assert.equal(200, r.status); |
| 43 | + done(); |
| 44 | + }); |
| 45 | + }); |
| 46 | +}); |
0 commit comments