|
| 1 | +import assert from 'assert'; |
| 2 | +import { Client } from '../lib'; |
| 3 | +import nock from 'nock'; |
| 4 | + |
| 5 | +describe('notes', () => { |
| 6 | + const client = new Client({ |
| 7 | + usernameAuth: { username: 'foo', password: 'bar' }, |
| 8 | + }); |
| 9 | + |
| 10 | + it('creates new', async () => { |
| 11 | + const contactId = 'baz'; |
| 12 | + const requestBody = { |
| 13 | + body: 'Shiny', |
| 14 | + admin_id: '12345', |
| 15 | + }; |
| 16 | + |
| 17 | + nock('https://api.intercom.io') |
| 18 | + .post(`/contacts/${contactId}/notes`, requestBody) |
| 19 | + .reply(200, {}); |
| 20 | + const response = await client.notes.create({ |
| 21 | + adminId: requestBody.admin_id, |
| 22 | + body: requestBody.body, |
| 23 | + contactId, |
| 24 | + }); |
| 25 | + |
| 26 | + assert.deepStrictEqual({}, response); |
| 27 | + }); |
| 28 | + it('finds by id', async () => { |
| 29 | + const id = 'beb'; |
| 30 | + |
| 31 | + nock('https://api.intercom.io').get(`/notes/${id}`).reply(200, {}); |
| 32 | + const response = await client.notes.find({ id }); |
| 33 | + |
| 34 | + assert.deepStrictEqual({}, response); |
| 35 | + }); |
| 36 | + it('lists all for specific contact by id', async () => { |
| 37 | + const contactId = 'yoopi'; |
| 38 | + |
| 39 | + nock('https://api.intercom.io') |
| 40 | + .get(`/contacts/${contactId}/notes`) |
| 41 | + .query({ page: 2, per_page: 3 }) |
| 42 | + .reply(200, {}); |
| 43 | + const response = await client.notes.list({ |
| 44 | + contactId, |
| 45 | + page: 2, |
| 46 | + perPage: 3, |
| 47 | + }); |
| 48 | + |
| 49 | + assert.deepStrictEqual({}, response); |
| 50 | + }); |
| 51 | +}); |
0 commit comments