|
| 1 | +import assert from 'assert'; |
| 2 | +import { Client, CountEntity, CountType } from '../lib'; |
| 3 | +import nock from 'nock'; |
| 4 | + |
| 5 | +describe.only('counts', () => { |
| 6 | + const client = new Client({ |
| 7 | + usernameAuth: { username: 'foo', password: 'bar' }, |
| 8 | + }); |
| 9 | + it('gets total app count', async () => { |
| 10 | + nock('https://api.intercom.io').get('/counts').reply(200, {}); |
| 11 | + const response = await client.counts.forApp(); |
| 12 | + |
| 13 | + assert.deepStrictEqual({}, response); |
| 14 | + }); |
| 15 | + it('gets conversations count', async () => { |
| 16 | + nock('https://api.intercom.io') |
| 17 | + .get('/counts') |
| 18 | + .query({ type: CountType.CONVERSATION }) |
| 19 | + .reply(200, {}); |
| 20 | + const response = await client.counts.countConversation(); |
| 21 | + |
| 22 | + assert.deepStrictEqual({}, response); |
| 23 | + }); |
| 24 | + it('gets admin conversations count', async () => { |
| 25 | + nock('https://api.intercom.io') |
| 26 | + .get('/counts') |
| 27 | + .query({ type: CountType.CONVERSATION, count: CountEntity.ADMIN }) |
| 28 | + .reply(200, {}); |
| 29 | + const response = await client.counts.countAdminConversation(); |
| 30 | + |
| 31 | + assert.deepStrictEqual({}, response); |
| 32 | + }); |
| 33 | + describe('for user', () => { |
| 34 | + it('gets segment count', async () => { |
| 35 | + nock('https://api.intercom.io') |
| 36 | + .get('/counts') |
| 37 | + .query({ type: CountType.USER, count: CountEntity.SEGMENT }) |
| 38 | + .reply(200, {}); |
| 39 | + const response = await client.counts.countUserSegment(); |
| 40 | + |
| 41 | + assert.deepStrictEqual({}, response); |
| 42 | + }); |
| 43 | + |
| 44 | + it('gets tags count', async () => { |
| 45 | + nock('https://api.intercom.io') |
| 46 | + .get('/counts') |
| 47 | + .query({ type: CountType.USER, count: CountEntity.TAG }) |
| 48 | + .reply(200, {}); |
| 49 | + const response = await client.counts.countUserTag(); |
| 50 | + |
| 51 | + assert.deepStrictEqual({}, response); |
| 52 | + }); |
| 53 | + }); |
| 54 | + describe('for company', () => { |
| 55 | + it('gets segment count', async () => { |
| 56 | + nock('https://api.intercom.io') |
| 57 | + .get('/counts') |
| 58 | + .query({ type: CountType.COMPANY, count: CountEntity.SEGMENT }) |
| 59 | + .reply(200, {}); |
| 60 | + const response = await client.counts.countCompanySegment(); |
| 61 | + |
| 62 | + assert.deepStrictEqual({}, response); |
| 63 | + }); |
| 64 | + |
| 65 | + it('gets tags count', async () => { |
| 66 | + nock('https://api.intercom.io') |
| 67 | + .get('/counts') |
| 68 | + .query({ type: CountType.COMPANY, count: CountEntity.TAG }) |
| 69 | + .reply(200, {}); |
| 70 | + const response = await client.counts.countCompanyTag(); |
| 71 | + |
| 72 | + assert.deepStrictEqual({}, response); |
| 73 | + }); |
| 74 | + |
| 75 | + it('gets users count', async () => { |
| 76 | + nock('https://api.intercom.io') |
| 77 | + .get('/counts') |
| 78 | + .query({ type: CountType.COMPANY, count: CountEntity.USER }) |
| 79 | + .reply(200, {}); |
| 80 | + const response = await client.counts.countCompanyUser(); |
| 81 | + |
| 82 | + assert.deepStrictEqual({}, response); |
| 83 | + }); |
| 84 | + }); |
| 85 | +}); |
0 commit comments