-
Notifications
You must be signed in to change notification settings - Fork 407
/
base.test.js
40 lines (34 loc) · 1.31 KB
/
base.test.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
33
34
35
36
37
38
39
40
'use strict';
var request = require('request');
var version = require('../package.json').version;
var Airtable = require('../lib/airtable');
jest.mock('request');
describe('Base', function() {
describe('#runAction', function() {
it('makes requests with the right options', function() {
var fakeAirtable = new Airtable({
apiKey: 'keyXyz',
requestTimeout: 1234
});
var fakeBase = fakeAirtable.base('app123');
fakeBase.runAction('get', '/my_table/rec456', {}, null, function() {});
expect(request).toHaveBeenCalledTimes(1);
expect(request).toHaveBeenCalledWith({
method: 'GET',
url: 'https://api.airtable.com/v0/app123/my_table/rec456?',
json: true,
timeout: 1234,
headers: {
authorization: 'Bearer keyXyz',
'x-api-version': '0.1.0',
'x-airtable-application-id': 'app123',
'User-Agent': 'Airtable.js/' + version
},
agentOptions: {
rejectUnauthorized: false
}
}, expect.any(Function));
expect(version).toEqual(expect.stringMatching(/^\d+\.\d+\.\d+$/));
});
});
});