@2bad/bitrix 2.4.0 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +0 -0
- package/README.md +54 -49
- package/build/main/bitrix.d.ts +10 -2
- package/build/main/bitrix.integration.test.d.ts +0 -0
- package/build/main/bitrix.integration.test.js +31 -0
- package/build/main/bitrix.js +24 -10
- package/build/main/bitrix.unit.test.d.ts +1 -0
- package/build/main/bitrix.unit.test.js +44 -0
- package/build/main/client/client.unit.test.d.ts +1 -0
- package/build/main/client/client.unit.test.js +70 -0
- package/build/main/client/hooks/addAccessToken.d.ts +4 -1
- package/build/main/client/hooks/addAccessToken.js +3 -1
- package/build/main/client/hooks/addAccessToken.unit.test.d.ts +1 -0
- package/build/main/client/hooks/addAccessToken.unit.test.js +31 -0
- package/build/main/client/index.d.ts +9 -1
- package/build/main/client/index.js +17 -6
- package/build/main/client/methods/batch.d.ts +19 -0
- package/build/main/client/methods/batch.js +35 -10
- package/build/main/client/methods/batch.unit.test.d.ts +1 -0
- package/build/main/client/methods/batch.unit.test.js +494 -0
- package/build/main/client/methods/call.d.ts +7 -0
- package/build/main/client/methods/call.js +11 -4
- package/build/main/client/methods/call.unit.test.d.ts +1 -0
- package/build/main/client/methods/call.unit.test.js +183 -0
- package/build/main/client/methods/list.d.ts +12 -0
- package/build/main/client/methods/list.js +23 -7
- package/build/main/client/methods/list.unit.test.d.ts +1 -0
- package/build/main/client/methods/list.unit.test.js +277 -0
- package/build/main/commands.js +0 -1
- package/build/main/methods.d.ts +19 -0
- package/build/main/methods.js +0 -1
- package/build/main/payloads.js +0 -1
- package/build/main/services/common.d.ts +1 -0
- package/build/main/services/common.js +0 -1
- package/build/main/services/companies/entities.js +0 -1
- package/build/main/services/companies/index.integration.test.d.ts +1 -0
- package/build/main/services/companies/index.integration.test.js +19 -0
- package/build/main/services/companies/index.js +0 -1
- package/build/main/services/companies/index.unit.test.d.ts +1 -0
- package/build/main/services/companies/index.unit.test.js +72 -0
- package/build/main/services/companies/methods.js +0 -1
- package/build/main/services/contacts/entities.d.ts +2 -2
- package/build/main/services/contacts/entities.js +0 -1
- package/build/main/services/contacts/index.integration.test.d.ts +1 -0
- package/build/main/services/contacts/index.integration.test.js +19 -0
- package/build/main/services/contacts/index.js +0 -1
- package/build/main/services/contacts/index.unit.test.d.ts +1 -0
- package/build/main/services/contacts/index.unit.test.js +72 -0
- package/build/main/services/contacts/methods.js +0 -1
- package/build/main/services/currencies/entities.js +0 -1
- package/build/main/services/deals/entities.js +0 -1
- package/build/main/services/deals/index.integration.test.d.ts +1 -0
- package/build/main/services/deals/index.integration.test.js +19 -0
- package/build/main/services/deals/index.js +0 -1
- package/build/main/services/deals/index.unit.test.d.ts +1 -0
- package/build/main/services/deals/index.unit.test.js +72 -0
- package/build/main/services/deals/methods.js +0 -1
- package/build/main/services/leads/entities.js +0 -1
- package/build/main/services/leads/index.integration.test.d.ts +1 -0
- package/build/main/services/leads/index.integration.test.js +19 -0
- package/build/main/services/leads/index.js +0 -1
- package/build/main/services/leads/index.unit.test.d.ts +1 -0
- package/build/main/services/leads/index.unit.test.js +72 -0
- package/build/main/services/leads/methods.js +0 -1
- package/build/main/services/statuses/entities.js +0 -1
- package/build/main/services/statuses/index.integration.test.d.ts +1 -0
- package/build/main/services/statuses/index.integration.test.js +90 -0
- package/build/main/services/statuses/index.js +0 -1
- package/build/main/services/statuses/index.unit.test.d.ts +1 -0
- package/build/main/services/statuses/index.unit.test.js +60 -0
- package/build/main/services/statuses/methods.js +0 -1
- package/build/main/services/users/entities.js +0 -1
- package/build/main/services/users/index.d.ts +1 -1
- package/build/main/services/users/index.integration.test.d.ts +1 -0
- package/build/main/services/users/index.integration.test.js +33 -0
- package/build/main/services/users/index.js +0 -1
- package/build/main/services/users/index.unit.test.d.ts +1 -0
- package/build/main/services/users/index.unit.test.js +25 -0
- package/build/main/services/users/methods.js +0 -1
- package/build/main/utils/Diff.js +0 -1
- package/build/main/utils/ExtractValue.d.ts +5 -0
- package/build/main/utils/ExtractValue.js +0 -1
- package/build/main/utils/isArray.js +1 -1
- package/build/module/bitrix.d.ts +10 -2
- package/build/module/bitrix.integration.test.d.ts +0 -0
- package/build/module/bitrix.integration.test.js +31 -0
- package/build/module/bitrix.js +10 -2
- package/build/module/bitrix.unit.test.d.ts +1 -0
- package/build/module/bitrix.unit.test.js +16 -0
- package/build/module/client/client.unit.test.d.ts +1 -0
- package/build/module/client/client.unit.test.js +65 -0
- package/build/module/client/hooks/addAccessToken.d.ts +4 -1
- package/build/module/client/hooks/addAccessToken.js +3 -1
- package/build/module/client/hooks/addAccessToken.unit.test.d.ts +1 -0
- package/build/module/client/hooks/addAccessToken.unit.test.js +26 -0
- package/build/module/client/index.d.ts +9 -1
- package/build/module/client/index.js +14 -3
- package/build/module/client/methods/batch.d.ts +19 -0
- package/build/module/client/methods/batch.js +26 -1
- package/build/module/client/methods/batch.unit.test.d.ts +1 -0
- package/build/module/client/methods/batch.unit.test.js +466 -0
- package/build/module/client/methods/call.d.ts +7 -0
- package/build/module/client/methods/call.js +9 -3
- package/build/module/client/methods/call.unit.test.d.ts +1 -0
- package/build/module/client/methods/call.unit.test.js +155 -0
- package/build/module/client/methods/list.d.ts +12 -0
- package/build/module/client/methods/list.js +20 -6
- package/build/module/client/methods/list.unit.test.d.ts +1 -0
- package/build/module/client/methods/list.unit.test.js +252 -0
- package/build/module/commands.js +0 -1
- package/build/module/methods.d.ts +19 -0
- package/build/module/methods.js +0 -1
- package/build/module/payloads.js +0 -1
- package/build/module/services/common.d.ts +1 -0
- package/build/module/services/common.js +0 -1
- package/build/module/services/companies/entities.js +0 -1
- package/build/module/services/companies/index.integration.test.d.ts +1 -0
- package/build/module/services/companies/index.integration.test.js +14 -0
- package/build/module/services/companies/index.js +0 -1
- package/build/module/services/companies/index.unit.test.d.ts +1 -0
- package/build/module/services/companies/index.unit.test.js +67 -0
- package/build/module/services/companies/methods.js +0 -1
- package/build/module/services/contacts/entities.d.ts +2 -2
- package/build/module/services/contacts/entities.js +0 -1
- package/build/module/services/contacts/index.integration.test.d.ts +1 -0
- package/build/module/services/contacts/index.integration.test.js +14 -0
- package/build/module/services/contacts/index.js +0 -1
- package/build/module/services/contacts/index.unit.test.d.ts +1 -0
- package/build/module/services/contacts/index.unit.test.js +67 -0
- package/build/module/services/contacts/methods.js +0 -1
- package/build/module/services/currencies/entities.js +0 -1
- package/build/module/services/deals/entities.js +0 -1
- package/build/module/services/deals/index.integration.test.d.ts +1 -0
- package/build/module/services/deals/index.integration.test.js +14 -0
- package/build/module/services/deals/index.js +0 -1
- package/build/module/services/deals/index.unit.test.d.ts +1 -0
- package/build/module/services/deals/index.unit.test.js +67 -0
- package/build/module/services/deals/methods.js +0 -1
- package/build/module/services/leads/entities.js +0 -1
- package/build/module/services/leads/index.integration.test.d.ts +1 -0
- package/build/module/services/leads/index.integration.test.js +14 -0
- package/build/module/services/leads/index.js +0 -1
- package/build/module/services/leads/index.unit.test.d.ts +1 -0
- package/build/module/services/leads/index.unit.test.js +67 -0
- package/build/module/services/leads/methods.js +0 -1
- package/build/module/services/statuses/entities.js +0 -1
- package/build/module/services/statuses/index.integration.test.d.ts +1 -0
- package/build/module/services/statuses/index.integration.test.js +85 -0
- package/build/module/services/statuses/index.js +0 -1
- package/build/module/services/statuses/index.unit.test.d.ts +1 -0
- package/build/module/services/statuses/index.unit.test.js +55 -0
- package/build/module/services/statuses/methods.js +0 -1
- package/build/module/services/users/entities.js +0 -1
- package/build/module/services/users/index.d.ts +1 -1
- package/build/module/services/users/index.integration.test.d.ts +1 -0
- package/build/module/services/users/index.integration.test.js +28 -0
- package/build/module/services/users/index.js +0 -1
- package/build/module/services/users/index.unit.test.d.ts +1 -0
- package/build/module/services/users/index.unit.test.js +20 -0
- package/build/module/services/users/methods.js +0 -1
- package/build/module/utils/Diff.js +0 -1
- package/build/module/utils/ExtractValue.d.ts +5 -0
- package/build/module/utils/ExtractValue.js +0 -1
- package/build/module/utils/isArray.js +1 -1
- package/package.json +21 -22
- package/build/main/bitrix.js.map +0 -1
- package/build/main/client/hooks/addAccessToken.js.map +0 -1
- package/build/main/client/index.js.map +0 -1
- package/build/main/client/methods/batch.js.map +0 -1
- package/build/main/client/methods/call.js.map +0 -1
- package/build/main/client/methods/list.js.map +0 -1
- package/build/main/commands.js.map +0 -1
- package/build/main/methods.js.map +0 -1
- package/build/main/payloads.js.map +0 -1
- package/build/main/services/common.js.map +0 -1
- package/build/main/services/companies/entities.js.map +0 -1
- package/build/main/services/companies/index.js.map +0 -1
- package/build/main/services/companies/methods.js.map +0 -1
- package/build/main/services/contacts/entities.js.map +0 -1
- package/build/main/services/contacts/index.js.map +0 -1
- package/build/main/services/contacts/methods.js.map +0 -1
- package/build/main/services/currencies/entities.js.map +0 -1
- package/build/main/services/deals/entities.js.map +0 -1
- package/build/main/services/deals/index.js.map +0 -1
- package/build/main/services/deals/methods.js.map +0 -1
- package/build/main/services/leads/entities.js.map +0 -1
- package/build/main/services/leads/index.js.map +0 -1
- package/build/main/services/leads/methods.js.map +0 -1
- package/build/main/services/statuses/entities.js.map +0 -1
- package/build/main/services/statuses/index.js.map +0 -1
- package/build/main/services/statuses/methods.js.map +0 -1
- package/build/main/services/users/entities.js.map +0 -1
- package/build/main/services/users/index.js.map +0 -1
- package/build/main/services/users/methods.js.map +0 -1
- package/build/main/utils/Diff.js.map +0 -1
- package/build/main/utils/ExtractValue.js.map +0 -1
- package/build/main/utils/isArray.js.map +0 -1
- package/build/module/bitrix.js.map +0 -1
- package/build/module/client/hooks/addAccessToken.js.map +0 -1
- package/build/module/client/index.js.map +0 -1
- package/build/module/client/methods/batch.js.map +0 -1
- package/build/module/client/methods/call.js.map +0 -1
- package/build/module/client/methods/list.js.map +0 -1
- package/build/module/commands.js.map +0 -1
- package/build/module/methods.js.map +0 -1
- package/build/module/payloads.js.map +0 -1
- package/build/module/services/common.js.map +0 -1
- package/build/module/services/companies/entities.js.map +0 -1
- package/build/module/services/companies/index.js.map +0 -1
- package/build/module/services/companies/methods.js.map +0 -1
- package/build/module/services/contacts/entities.js.map +0 -1
- package/build/module/services/contacts/index.js.map +0 -1
- package/build/module/services/contacts/methods.js.map +0 -1
- package/build/module/services/currencies/entities.js.map +0 -1
- package/build/module/services/deals/entities.js.map +0 -1
- package/build/module/services/deals/index.js.map +0 -1
- package/build/module/services/deals/methods.js.map +0 -1
- package/build/module/services/leads/entities.js.map +0 -1
- package/build/module/services/leads/index.js.map +0 -1
- package/build/module/services/leads/methods.js.map +0 -1
- package/build/module/services/statuses/entities.js.map +0 -1
- package/build/module/services/statuses/index.js.map +0 -1
- package/build/module/services/statuses/methods.js.map +0 -1
- package/build/module/services/users/entities.js.map +0 -1
- package/build/module/services/users/index.js.map +0 -1
- package/build/module/services/users/methods.js.map +0 -1
- package/build/module/utils/Diff.js.map +0 -1
- package/build/module/utils/ExtractValue.js.map +0 -1
- package/build/module/utils/isArray.js.map +0 -1
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const _1 = __importDefault(require("."));
|
|
7
|
+
const mockCall = jest.fn(() => Promise.resolve());
|
|
8
|
+
const mockList = jest.fn(() => Promise.resolve());
|
|
9
|
+
const companies = (0, _1.default)({ call: mockCall, list: mockList });
|
|
10
|
+
const ID = '77';
|
|
11
|
+
describe('Companies', () => {
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
mockCall.mockClear();
|
|
14
|
+
mockList.mockClear();
|
|
15
|
+
});
|
|
16
|
+
it('should expose API methods', () => {
|
|
17
|
+
expect(companies).toMatchSnapshot();
|
|
18
|
+
});
|
|
19
|
+
describe('`create`', () => {
|
|
20
|
+
it('should invoke `call`', async () => {
|
|
21
|
+
await companies.create({
|
|
22
|
+
COMMENTS: 'Some comment'
|
|
23
|
+
}, {
|
|
24
|
+
REGISTER_SONET_EVENT: 'Y'
|
|
25
|
+
});
|
|
26
|
+
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
27
|
+
});
|
|
28
|
+
it('should work without optional params', async () => {
|
|
29
|
+
await companies.create({
|
|
30
|
+
COMMENTS: 'Some comment'
|
|
31
|
+
});
|
|
32
|
+
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
describe('`get`', () => {
|
|
36
|
+
it('should invoke `call`', async () => {
|
|
37
|
+
await companies.get(ID);
|
|
38
|
+
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
describe('`list`', () => {
|
|
42
|
+
it('should invoke `list`', async () => {
|
|
43
|
+
await companies.list({
|
|
44
|
+
start: 0,
|
|
45
|
+
order: { COMMENTS: 'ASC' },
|
|
46
|
+
filter: { '>PROBABILITY': 50 },
|
|
47
|
+
select: ['*', 'UF_*']
|
|
48
|
+
});
|
|
49
|
+
expect(mockList.mock.calls).toMatchSnapshot();
|
|
50
|
+
});
|
|
51
|
+
it('should work without optional params', async () => {
|
|
52
|
+
await companies.list();
|
|
53
|
+
expect(mockList.mock.calls).toMatchSnapshot();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
describe('`update`', () => {
|
|
57
|
+
it('should invoke `call`', async () => {
|
|
58
|
+
await companies.update(ID, {
|
|
59
|
+
COMMENTS: 'Some comment'
|
|
60
|
+
}, {
|
|
61
|
+
REGISTER_SONET_EVENT: 'Y'
|
|
62
|
+
});
|
|
63
|
+
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
64
|
+
});
|
|
65
|
+
it('should work without optional params', async () => {
|
|
66
|
+
await companies.update(ID, {
|
|
67
|
+
COMMENTS: 'Some comment'
|
|
68
|
+
});
|
|
69
|
+
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BoolString, ISODate, NumberString } from '../common';
|
|
1
|
+
import { BoolString, ISODate, MultiFieldArray, NumberString } from '../common';
|
|
2
2
|
export declare type Contact = {
|
|
3
|
-
readonly [key: string]: string | null;
|
|
3
|
+
readonly [key: string]: MultiFieldArray | string | null;
|
|
4
4
|
readonly ID: NumberString;
|
|
5
5
|
readonly POST: string | null;
|
|
6
6
|
readonly COMMENTS: string | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const bitrix_1 = __importDefault(require("./../../bitrix"));
|
|
7
|
+
const WEBHOOK_URL = process.env['WEBHOOK_URL'];
|
|
8
|
+
if (!WEBHOOK_URL) {
|
|
9
|
+
throw Error('Integration tests require environmental variable `WEBHOOK_URL` to be set');
|
|
10
|
+
}
|
|
11
|
+
const { contacts } = (0, bitrix_1.default)(WEBHOOK_URL);
|
|
12
|
+
describe('Contacts', () => {
|
|
13
|
+
describe('fields', () => {
|
|
14
|
+
it('should get all fields', async () => {
|
|
15
|
+
const { result } = await contacts.fields();
|
|
16
|
+
expect(result).toMatchSnapshot();
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const _1 = __importDefault(require("."));
|
|
7
|
+
const mockCall = jest.fn(() => Promise.resolve());
|
|
8
|
+
const mockList = jest.fn(() => Promise.resolve());
|
|
9
|
+
const contacts = (0, _1.default)({ call: mockCall, list: mockList });
|
|
10
|
+
const ID = '77';
|
|
11
|
+
describe('Contacts', () => {
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
mockCall.mockClear();
|
|
14
|
+
mockList.mockClear();
|
|
15
|
+
});
|
|
16
|
+
it('should expose API methods', () => {
|
|
17
|
+
expect(contacts).toMatchSnapshot();
|
|
18
|
+
});
|
|
19
|
+
describe('`create`', () => {
|
|
20
|
+
it('should invoke `call`', async () => {
|
|
21
|
+
await contacts.create({
|
|
22
|
+
COMMENTS: 'Some comment'
|
|
23
|
+
}, {
|
|
24
|
+
REGISTER_SONET_EVENT: 'Y'
|
|
25
|
+
});
|
|
26
|
+
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
27
|
+
});
|
|
28
|
+
it('should work without optional params', async () => {
|
|
29
|
+
await contacts.create({
|
|
30
|
+
COMMENTS: 'Some comment'
|
|
31
|
+
});
|
|
32
|
+
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
describe('`get`', () => {
|
|
36
|
+
it('should invoke `call`', async () => {
|
|
37
|
+
await contacts.get(ID);
|
|
38
|
+
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
describe('`list`', () => {
|
|
42
|
+
it('should invoke `list`', async () => {
|
|
43
|
+
await contacts.list({
|
|
44
|
+
start: 0,
|
|
45
|
+
order: { COMMENTS: 'ASC' },
|
|
46
|
+
filter: { '>PROBABILITY': 50 },
|
|
47
|
+
select: ['*', 'UF_*']
|
|
48
|
+
});
|
|
49
|
+
expect(mockList.mock.calls).toMatchSnapshot();
|
|
50
|
+
});
|
|
51
|
+
it('should work without optional params', async () => {
|
|
52
|
+
await contacts.list();
|
|
53
|
+
expect(mockList.mock.calls).toMatchSnapshot();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
describe('`update`', () => {
|
|
57
|
+
it('should invoke `call`', async () => {
|
|
58
|
+
await contacts.update(ID, {
|
|
59
|
+
COMMENTS: 'Some comment'
|
|
60
|
+
}, {
|
|
61
|
+
REGISTER_SONET_EVENT: 'Y'
|
|
62
|
+
});
|
|
63
|
+
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
64
|
+
});
|
|
65
|
+
it('should work without optional params', async () => {
|
|
66
|
+
await contacts.update(ID, {
|
|
67
|
+
COMMENTS: 'Some comment'
|
|
68
|
+
});
|
|
69
|
+
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const bitrix_1 = __importDefault(require("./../../bitrix"));
|
|
7
|
+
const WEBHOOK_URL = process.env['WEBHOOK_URL'];
|
|
8
|
+
if (!WEBHOOK_URL) {
|
|
9
|
+
throw Error('Integration tests require environmental variable `WEBHOOK_URL` to be set');
|
|
10
|
+
}
|
|
11
|
+
const { deals } = (0, bitrix_1.default)(WEBHOOK_URL);
|
|
12
|
+
describe('Deals', () => {
|
|
13
|
+
describe('fields', () => {
|
|
14
|
+
it('should get all fields', async () => {
|
|
15
|
+
const { result } = await deals.fields();
|
|
16
|
+
expect(result).toMatchSnapshot();
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const _1 = __importDefault(require("."));
|
|
7
|
+
const mockCall = jest.fn(() => Promise.resolve());
|
|
8
|
+
const mockList = jest.fn(() => Promise.resolve());
|
|
9
|
+
const deals = (0, _1.default)({ call: mockCall, list: mockList });
|
|
10
|
+
const ID = '77';
|
|
11
|
+
describe('Deals', () => {
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
mockCall.mockClear();
|
|
14
|
+
mockList.mockClear();
|
|
15
|
+
});
|
|
16
|
+
it('should expose API methods', () => {
|
|
17
|
+
expect(deals).toMatchSnapshot();
|
|
18
|
+
});
|
|
19
|
+
describe('`create`', () => {
|
|
20
|
+
it('should invoke `call`', async () => {
|
|
21
|
+
await deals.create({
|
|
22
|
+
COMMENTS: 'Some comment'
|
|
23
|
+
}, {
|
|
24
|
+
REGISTER_SONET_EVENT: 'Y'
|
|
25
|
+
});
|
|
26
|
+
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
27
|
+
});
|
|
28
|
+
it('should work without optional params', async () => {
|
|
29
|
+
await deals.create({
|
|
30
|
+
COMMENTS: 'Some comment'
|
|
31
|
+
});
|
|
32
|
+
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
describe('`get`', () => {
|
|
36
|
+
it('should invoke `call`', async () => {
|
|
37
|
+
await deals.get(ID);
|
|
38
|
+
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
describe('`list`', () => {
|
|
42
|
+
it('should invoke `list`', async () => {
|
|
43
|
+
await deals.list({
|
|
44
|
+
start: 0,
|
|
45
|
+
order: { COMMENTS: 'ASC' },
|
|
46
|
+
filter: { '>PROBABILITY': 50 },
|
|
47
|
+
select: ['*', 'UF_*']
|
|
48
|
+
});
|
|
49
|
+
expect(mockList.mock.calls).toMatchSnapshot();
|
|
50
|
+
});
|
|
51
|
+
it('should work without optional params', async () => {
|
|
52
|
+
await deals.list();
|
|
53
|
+
expect(mockList.mock.calls).toMatchSnapshot();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
describe('`update`', () => {
|
|
57
|
+
it('should invoke `call`', async () => {
|
|
58
|
+
await deals.update(ID, {
|
|
59
|
+
COMMENTS: 'Some comment'
|
|
60
|
+
}, {
|
|
61
|
+
REGISTER_SONET_EVENT: 'Y'
|
|
62
|
+
});
|
|
63
|
+
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
64
|
+
});
|
|
65
|
+
it('should work without optional params', async () => {
|
|
66
|
+
await deals.update(ID, {
|
|
67
|
+
COMMENTS: 'Some comment'
|
|
68
|
+
});
|
|
69
|
+
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const bitrix_1 = __importDefault(require("./../../bitrix"));
|
|
7
|
+
const WEBHOOK_URL = process.env['WEBHOOK_URL'];
|
|
8
|
+
if (!WEBHOOK_URL) {
|
|
9
|
+
throw Error('Integration tests require environmental variable `WEBHOOK_URL` to be set');
|
|
10
|
+
}
|
|
11
|
+
const { leads } = (0, bitrix_1.default)(WEBHOOK_URL);
|
|
12
|
+
describe('Leads', () => {
|
|
13
|
+
describe('fields', () => {
|
|
14
|
+
it('should get all fields', async () => {
|
|
15
|
+
const { result } = await leads.fields();
|
|
16
|
+
expect(result).toMatchSnapshot();
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const _1 = __importDefault(require("."));
|
|
7
|
+
const mockCall = jest.fn(() => Promise.resolve());
|
|
8
|
+
const mockList = jest.fn(() => Promise.resolve());
|
|
9
|
+
const leads = (0, _1.default)({ call: mockCall, list: mockList });
|
|
10
|
+
const ID = '77';
|
|
11
|
+
describe('Leads', () => {
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
mockCall.mockClear();
|
|
14
|
+
mockList.mockClear();
|
|
15
|
+
});
|
|
16
|
+
it('should expose API methods', () => {
|
|
17
|
+
expect(leads).toMatchSnapshot();
|
|
18
|
+
});
|
|
19
|
+
describe('`create`', () => {
|
|
20
|
+
it('should invoke `call`', async () => {
|
|
21
|
+
await leads.create({
|
|
22
|
+
COMMENTS: 'Some comment'
|
|
23
|
+
}, {
|
|
24
|
+
REGISTER_SONET_EVENT: 'Y'
|
|
25
|
+
});
|
|
26
|
+
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
27
|
+
});
|
|
28
|
+
it('should work without optional params', async () => {
|
|
29
|
+
await leads.create({
|
|
30
|
+
COMMENTS: 'Some comment'
|
|
31
|
+
});
|
|
32
|
+
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
describe('`get`', () => {
|
|
36
|
+
it('should invoke `call`', async () => {
|
|
37
|
+
await leads.get(ID);
|
|
38
|
+
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
describe('`list`', () => {
|
|
42
|
+
it('should invoke `list`', async () => {
|
|
43
|
+
await leads.list({
|
|
44
|
+
start: 0,
|
|
45
|
+
order: { COMMENTS: 'ASC' },
|
|
46
|
+
filter: { '>PROBABILITY': 50 },
|
|
47
|
+
select: ['*', 'UF_*']
|
|
48
|
+
});
|
|
49
|
+
expect(mockList.mock.calls).toMatchSnapshot();
|
|
50
|
+
});
|
|
51
|
+
it('should work without optional params', async () => {
|
|
52
|
+
await leads.list();
|
|
53
|
+
expect(mockList.mock.calls).toMatchSnapshot();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
describe('`update`', () => {
|
|
57
|
+
it('should invoke `call`', async () => {
|
|
58
|
+
await leads.update(ID, {
|
|
59
|
+
COMMENTS: 'Some comment'
|
|
60
|
+
}, {
|
|
61
|
+
REGISTER_SONET_EVENT: 'Y'
|
|
62
|
+
});
|
|
63
|
+
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
64
|
+
});
|
|
65
|
+
it('should work without optional params', async () => {
|
|
66
|
+
await leads.update(ID, {
|
|
67
|
+
COMMENTS: 'Some comment'
|
|
68
|
+
});
|
|
69
|
+
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const bitrix_1 = __importDefault(require("../../bitrix"));
|
|
7
|
+
// @ts-ignore this should be improved in a future but it works for now
|
|
8
|
+
const isSortedAsc = (arr) => arr.slice(1).every((v, i) => arr[i] <= v);
|
|
9
|
+
// @ts-ignore this should be improved in a future but it works for now
|
|
10
|
+
const isSortedDesc = (arr) => arr.slice(1).every((v, i) => arr[i] >= v);
|
|
11
|
+
const WEBHOOK_URL = process.env['WEBHOOK_URL'];
|
|
12
|
+
if (!WEBHOOK_URL) {
|
|
13
|
+
throw Error('Integration tests require environmental variable `WEBHOOK_URL` to be set');
|
|
14
|
+
}
|
|
15
|
+
const { statuses } = (0, bitrix_1.default)(WEBHOOK_URL);
|
|
16
|
+
describe('Statuses', () => {
|
|
17
|
+
describe('fields', () => {
|
|
18
|
+
it('should get all fields', async () => {
|
|
19
|
+
const { result } = await statuses.fields();
|
|
20
|
+
expect(result).toMatchSnapshot();
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
describe('list', () => {
|
|
24
|
+
it('should get all entries without optional parameters', async () => {
|
|
25
|
+
const { result } = await statuses.list();
|
|
26
|
+
expect(result).toMatchSnapshot();
|
|
27
|
+
});
|
|
28
|
+
it('should return only entries with ENTITY_ID = STATUS sorted in ascending order', async () => {
|
|
29
|
+
const { result } = await statuses.list({
|
|
30
|
+
order: { SORT: 'ASC' },
|
|
31
|
+
filter: { ENTITY_ID: 'STATUS' }
|
|
32
|
+
});
|
|
33
|
+
expect(result.every((s) => s.ENTITY_ID === 'STATUS')).toBeTruthy();
|
|
34
|
+
expect(isSortedAsc(result.map((s) => s.SORT))).toBeTruthy();
|
|
35
|
+
expect(result).toMatchSnapshot();
|
|
36
|
+
});
|
|
37
|
+
it('should return only entries with ENTITY_ID = STATUS sorted in descending order', async () => {
|
|
38
|
+
const { result } = await statuses.list({
|
|
39
|
+
order: { SORT: 'DESC' },
|
|
40
|
+
filter: { ENTITY_ID: 'STATUS' }
|
|
41
|
+
});
|
|
42
|
+
expect(result.every((s) => s.ENTITY_ID === 'STATUS')).toBeTruthy();
|
|
43
|
+
expect(isSortedDesc(result.map((s) => s.SORT))).toBeTruthy();
|
|
44
|
+
expect(result).toMatchSnapshot();
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
describe('get', () => {
|
|
48
|
+
it('should get entry with ID = 1', async () => {
|
|
49
|
+
const { result } = await statuses.get('1');
|
|
50
|
+
expect(result).toMatchSnapshot();
|
|
51
|
+
});
|
|
52
|
+
it('should return an error in case non existent ID is requested', async () => {
|
|
53
|
+
const get = statuses.get('1001');
|
|
54
|
+
await expect(get).rejects.toThrow(Error);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
describe('create', () => {
|
|
58
|
+
it('should create an entry', async () => {
|
|
59
|
+
const entry = {
|
|
60
|
+
ENTITY_ID: 'STATUS',
|
|
61
|
+
STATUS_ID: 'TEST',
|
|
62
|
+
NAME: 'TEST'
|
|
63
|
+
};
|
|
64
|
+
const { result: id } = await statuses.create(entry);
|
|
65
|
+
expect(id).toBeGreaterThan(0);
|
|
66
|
+
const { result: status } = await statuses.get(id);
|
|
67
|
+
expect(status).toMatchSnapshot({
|
|
68
|
+
ID: expect.any(String)
|
|
69
|
+
});
|
|
70
|
+
const { result: deleteResult } = await statuses.delete(id);
|
|
71
|
+
expect(deleteResult).toBeTruthy();
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
describe('update', () => {
|
|
75
|
+
it('should update an entry', async () => {
|
|
76
|
+
const STATUS_ID = 101;
|
|
77
|
+
const { result: status } = await statuses.get(STATUS_ID);
|
|
78
|
+
expect(status).toMatchSnapshot();
|
|
79
|
+
const { result: updateResult } = await statuses.update(STATUS_ID, {
|
|
80
|
+
...status,
|
|
81
|
+
NAME: 'CHANGED'
|
|
82
|
+
});
|
|
83
|
+
expect(updateResult).toBeTruthy();
|
|
84
|
+
const { result: updatedStatus } = await statuses.get(STATUS_ID);
|
|
85
|
+
expect(updatedStatus).toMatchSnapshot();
|
|
86
|
+
const { result: rollbackResult } = await statuses.update(STATUS_ID, status);
|
|
87
|
+
expect(rollbackResult).toBeTruthy();
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const _1 = __importDefault(require("."));
|
|
7
|
+
const mockCall = jest.fn(() => Promise.resolve());
|
|
8
|
+
const mockList = jest.fn(() => Promise.resolve());
|
|
9
|
+
const statuses = (0, _1.default)({ call: mockCall });
|
|
10
|
+
const ID = '77';
|
|
11
|
+
describe('Statuses', () => {
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
mockCall.mockClear();
|
|
14
|
+
mockList.mockClear();
|
|
15
|
+
});
|
|
16
|
+
it('should expose API methods', () => {
|
|
17
|
+
expect(statuses).toMatchSnapshot();
|
|
18
|
+
});
|
|
19
|
+
describe('`create`', () => {
|
|
20
|
+
it('should invoke `call`', async () => {
|
|
21
|
+
await statuses.create({
|
|
22
|
+
NAME: 'Test name'
|
|
23
|
+
});
|
|
24
|
+
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
describe('`get`', () => {
|
|
28
|
+
it('should invoke `call`', async () => {
|
|
29
|
+
await statuses.get(ID);
|
|
30
|
+
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
describe('`list`', () => {
|
|
34
|
+
it('should invoke `call`', async () => {
|
|
35
|
+
await statuses.list({
|
|
36
|
+
order: { NAME: 'ASC' },
|
|
37
|
+
filter: { ENTITY_ID: 'STATUS' }
|
|
38
|
+
});
|
|
39
|
+
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
40
|
+
});
|
|
41
|
+
it('should work without optional params', async () => {
|
|
42
|
+
await statuses.list();
|
|
43
|
+
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
describe('`update`', () => {
|
|
47
|
+
it('should invoke `call`', async () => {
|
|
48
|
+
await statuses.update(ID, {
|
|
49
|
+
NAME: 'Test name'
|
|
50
|
+
});
|
|
51
|
+
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
52
|
+
});
|
|
53
|
+
it('should work without optional params', async () => {
|
|
54
|
+
await statuses.update(ID, {
|
|
55
|
+
NAME: 'Test name'
|
|
56
|
+
});
|
|
57
|
+
expect(mockCall.mock.calls).toMatchSnapshot();
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
});
|
|
@@ -4,6 +4,6 @@ declare type Dependencies = {
|
|
|
4
4
|
};
|
|
5
5
|
declare const _default: ({ call }: Dependencies) => {
|
|
6
6
|
fields: () => Promise<import("../../payloads").GetPayload<import("./entities").User>>;
|
|
7
|
-
get: (id?: string
|
|
7
|
+
get: (id?: string) => Promise<import("../../payloads").GetPayload<readonly import("./entities").User[]>>;
|
|
8
8
|
};
|
|
9
9
|
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|