|
| 1 | +import assert from 'assert'; |
| 2 | +import {Client} from '../lib'; |
| 3 | +var nock = require('nock'); |
| 4 | + |
| 5 | +describe('companies', function () { |
| 6 | + it('should be created', function (done) { |
| 7 | + nock('https://api.intercom.io').post('/companies', { name: 'baz' }).reply(200, {}); |
| 8 | + let client = new Client('foo', 'bar'); |
| 9 | + client.companies.create({ name: 'baz' }, 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('/companies').reply(200, {}); |
| 16 | + let client = new Client('foo', 'bar'); |
| 17 | + client.companies.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('/companies').query({ tag_id: '1234' }).reply(200, {}); |
| 24 | + let client = new Client('foo', 'bar'); |
| 25 | + client.companies.listBy({ tag_id: '1234' }, function (r) { |
| 26 | + assert.equal(200, r.status); |
| 27 | + done(); |
| 28 | + }); |
| 29 | + }); |
| 30 | + it('find companies by id', function (done) { |
| 31 | + nock('https://api.intercom.io').get('/companies/baz').reply(200, {}); |
| 32 | + let client = new Client('foo', 'bar'); |
| 33 | + client.companies.find({ id: 'baz' }, function (r) { |
| 34 | + assert.equal(200, r.status); |
| 35 | + done(); |
| 36 | + }); |
| 37 | + }); |
| 38 | + it('list company users by id', function (done) { |
| 39 | + nock('https://api.intercom.io').get('/companies/baz/users').reply(200, {}); |
| 40 | + let client = new Client('foo', 'bar'); |
| 41 | + client.companies.listUsers({ id: 'baz' }, function (r) { |
| 42 | + assert.equal(200, r.status); |
| 43 | + done(); |
| 44 | + }); |
| 45 | + }); |
| 46 | +}); |
0 commit comments