-
Notifications
You must be signed in to change notification settings - Fork 4
/
fax.spec.js
32 lines (27 loc) · 1.1 KB
/
fax.spec.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
/* eslint-env jest */
import RingCentral from '../src/ringcentral'
import FormData from 'form-data'
import fs from 'fs'
import path from 'path'
import waitFor from 'wait-for-async'
jest.setTimeout(64000)
const rc = new RingCentral(process.env.RINGCENTRAL_CLIENT_ID, process.env.RINGCENTRAL_CLIENT_SECRET, process.env.RINGCENTRAL_SERVER_URL)
describe('ringcentral', () => {
test('fax', async () => {
await rc.authorize({
username: process.env.RINGCENTRAL_USERNAME,
extension: process.env.RINGCENTRAL_EXTENSION,
password: process.env.RINGCENTRAL_PASSWORD
})
const formData = new FormData()
formData.append('files[]', JSON.stringify({ to: [{ phoneNumber: process.env.RINGCENTRAL_RECEIVER }] }), 'test.json')
formData.append('files[]', 'Hello world', 'test.txt')
formData.append('files[]', fs.createReadStream(path.join(__dirname, 'test.png')), 'test.png')
const r = await rc.post('/restapi/v1.0/account/~/extension/~/fax', formData, {
headers: formData.getHeaders()
})
expect(r.status).toBe(200)
await waitFor({ interval: 1000 })
await rc.revoke()
})
})