@webitel/api-services 0.1.18 → 0.1.19
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/package.json +7 -2
- package/src/api/clients/chatGateways/defaults/webChatGateway.ts +12 -6
- package/src/api/clients/fileServices/fileServices.ts +2 -2
- package/src/api/clients/flows/flow.ts +2 -4
- package/src/api/clients/pdfServices/pdfServices.ts +2 -2
- package/src/api/clients/queues/queues.ts +2 -4
- package/src/api/clients/users/users.ts +8 -2
- package/src/api/clients//321/201ontacts/contacts.ts +1 -1
- package/src/api/defaults/getDefaultGetListResponse/getDefaultGetListResponse.ts +1 -1
- package/src/api/transformers/sanitize/sanitize.transformer.ts +2 -5
- package/src/gen/contacts/contacts.ts +8 -4
- package/types/api/clients/chatGateways/defaults/webChatGateway.d.ts +4 -1
- package/types/api/clients/fileServices/fileServices.d.ts +2 -2
- package/types/api/clients/pdfServices/pdfServices.d.ts +2 -2
- package/types/api/defaults/getDefaultGetListResponse/getDefaultGetListResponse.d.ts +1 -1
- package/types/gen/contacts/contacts.d.ts +2 -2
- package/src/api/clients/users/__tests__/users.spec.ts +0 -281
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webitel/api-services",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"private": false,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"make-all": "npm run gen:api && npm version patch && (npm run build:types || true) && (npm run format:all || true) && npm run publish-lib",
|
|
@@ -12,6 +12,11 @@
|
|
|
12
12
|
"gen:api:cleanup": "rm swagger.yaml formatted-openapi.yaml",
|
|
13
13
|
"build:types": "vue-tsc -p ./tsconfig.build.json",
|
|
14
14
|
"format:all": "npx biome check --write ./src",
|
|
15
|
+
"biome:ci:gh": "biome ci ./src --reporter=github",
|
|
16
|
+
"test:unit": "node -e \"process.exit(0)\"",
|
|
17
|
+
"lint": "biome ci ./src",
|
|
18
|
+
"test": "npm run test:unit",
|
|
19
|
+
"ci:check": "npm run biome:ci:gh && npm run test:unit && npm run lint:package",
|
|
15
20
|
"orval": "orval",
|
|
16
21
|
"lint:package": "publint",
|
|
17
22
|
"utils:i": "npm i"
|
|
@@ -30,7 +35,7 @@
|
|
|
30
35
|
"zod": "^4.3.6"
|
|
31
36
|
},
|
|
32
37
|
"devDependencies": {
|
|
33
|
-
"@biomejs/biome": "^2.
|
|
38
|
+
"@biomejs/biome": "^2.4.10",
|
|
34
39
|
"@tsconfig/node22": "^22.0.0",
|
|
35
40
|
"@types/node": "^22.13.10",
|
|
36
41
|
"axios": "1.13.2",
|
|
@@ -62,14 +62,20 @@ export const webChatGateway = (_btnCodeDirty = false) => ({
|
|
|
62
62
|
id: '',
|
|
63
63
|
},
|
|
64
64
|
alternativeChannels: Object.values(WebchatAlternativeChannel).reduce(
|
|
65
|
-
(channels, channel) =>
|
|
66
|
-
|
|
67
|
-
[channel]: {
|
|
65
|
+
(channels, channel) => {
|
|
66
|
+
channels[channel] = {
|
|
68
67
|
url: '',
|
|
69
68
|
enabled: false,
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
};
|
|
70
|
+
return channels;
|
|
71
|
+
},
|
|
72
|
+
{} as Record<
|
|
73
|
+
string,
|
|
74
|
+
{
|
|
75
|
+
url: string;
|
|
76
|
+
enabled: boolean;
|
|
77
|
+
}
|
|
78
|
+
>,
|
|
73
79
|
),
|
|
74
80
|
},
|
|
75
81
|
});
|
|
@@ -87,7 +87,7 @@ const deleteFiles = async (id) => {
|
|
|
87
87
|
}
|
|
88
88
|
};
|
|
89
89
|
|
|
90
|
-
const getScreenRecordingsByUser = async (params:
|
|
90
|
+
const getScreenRecordingsByUser = async (params: unknown) => {
|
|
91
91
|
const fieldsToSend = getShallowFieldsToSendFromZodSchema(
|
|
92
92
|
SearchScreenRecordingsQueryParams,
|
|
93
93
|
);
|
|
@@ -165,7 +165,7 @@ const deleteScreenRecordingsByUser = async ({ userId, id }) => {
|
|
|
165
165
|
}
|
|
166
166
|
};
|
|
167
167
|
|
|
168
|
-
const getScreenRecordingsByAgent = async (params:
|
|
168
|
+
const getScreenRecordingsByAgent = async (params: unknown) => {
|
|
169
169
|
const fieldsToSend = getShallowFieldsToSendFromZodSchema(
|
|
170
170
|
SearchScreenRecordingsByAgentQueryParams,
|
|
171
171
|
);
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
RoutingSchemaServiceApiFactory,
|
|
4
|
-
} from 'webitel-sdk';
|
|
1
|
+
import { EngineRoutingSchemaType } from '@webitel/api-services/gen/models';
|
|
2
|
+
import { RoutingSchemaServiceApiFactory } from 'webitel-sdk';
|
|
5
3
|
|
|
6
4
|
import {
|
|
7
5
|
getDefaultGetListResponse,
|
|
@@ -40,7 +40,7 @@ const createScreenrecordingExport = async ({ agentId, itemInstance }) => {
|
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
const listScreenrecordingExports = async (params:
|
|
43
|
+
const listScreenrecordingExports = async (params: unknown) => {
|
|
44
44
|
const fieldsToSend = getShallowFieldsToSendFromZodSchema(
|
|
45
45
|
ListScreenrecordingExportsQueryParams,
|
|
46
46
|
);
|
|
@@ -94,7 +94,7 @@ const createCallExport = async ({ callId, itemInstance }) => {
|
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
96
|
|
|
97
|
-
const listCallExports = async (params:
|
|
97
|
+
const listCallExports = async (params: unknown) => {
|
|
98
98
|
const fieldsToSend = getShallowFieldsToSendFromZodSchema(
|
|
99
99
|
ListCallExportsQueryParams,
|
|
100
100
|
);
|
|
@@ -58,10 +58,8 @@ const preRequestHandler = (item) => {
|
|
|
58
58
|
const copy = deepCopy(item);
|
|
59
59
|
copy.variables = copy.variables.reduce((variables, variable) => {
|
|
60
60
|
if (!variable.key) return variables;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
[variable.key]: variable.value,
|
|
64
|
-
};
|
|
61
|
+
variables[variable.key] = variable.value;
|
|
62
|
+
return variables;
|
|
65
63
|
}, {});
|
|
66
64
|
return copy;
|
|
67
65
|
};
|
|
@@ -145,9 +145,15 @@ const preRequestHandler = (item) => {
|
|
|
145
145
|
const copy = deepCopy(item);
|
|
146
146
|
if (item.device && !item.device.id) copy.device = undefined;
|
|
147
147
|
|
|
148
|
-
if (copy.roles)
|
|
148
|
+
if (copy.roles)
|
|
149
|
+
copy.roles.forEach((copy) => {
|
|
150
|
+
copy.text = undefined;
|
|
151
|
+
});
|
|
149
152
|
|
|
150
|
-
if (copy.devices)
|
|
153
|
+
if (copy.devices)
|
|
154
|
+
copy.devices.forEach((copy) => {
|
|
155
|
+
copy.text = undefined;
|
|
156
|
+
});
|
|
151
157
|
if (copy.license) {
|
|
152
158
|
copy.license = copy.license.map((copy) => ({
|
|
153
159
|
id: copy.id,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Creates a default response object for list operations
|
|
3
3
|
* @returns Default list response object with empty items array and next=false
|
|
4
4
|
*/
|
|
5
|
-
export const getDefaultGetListResponse = (
|
|
5
|
+
export const getDefaultGetListResponse = () => ({
|
|
6
6
|
items: [],
|
|
7
7
|
next: false,
|
|
8
8
|
});
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
const sanitizeTransformer = (fieldsToSend) => (item) => {
|
|
2
2
|
return Object.keys(item).reduce((sanitizedItem, key) => {
|
|
3
3
|
if (fieldsToSend.indexOf(key) === -1) return sanitizedItem;
|
|
4
|
-
|
|
5
|
-
return
|
|
6
|
-
...sanitizedItem,
|
|
7
|
-
[key]: item[key],
|
|
8
|
-
};
|
|
4
|
+
sanitizedItem[key] = item[key];
|
|
5
|
+
return sanitizedItem;
|
|
9
6
|
}, {});
|
|
10
7
|
};
|
|
11
8
|
|
|
@@ -32,12 +32,16 @@ type WritableKeys<T> = {
|
|
|
32
32
|
>;
|
|
33
33
|
}[keyof T];
|
|
34
34
|
|
|
35
|
-
type UnionToIntersection<U> = (
|
|
36
|
-
|
|
37
|
-
) => void
|
|
35
|
+
type UnionToIntersection<U> = (
|
|
36
|
+
U extends unknown
|
|
37
|
+
? (k: U) => void
|
|
38
|
+
: never
|
|
39
|
+
) extends (k: infer I) => void
|
|
38
40
|
? I
|
|
39
41
|
: never;
|
|
40
|
-
type DistributeReadOnlyOverUnions<T> = T extends
|
|
42
|
+
type DistributeReadOnlyOverUnions<T> = T extends unknown
|
|
43
|
+
? NonReadonly<T>
|
|
44
|
+
: never;
|
|
41
45
|
|
|
42
46
|
type Writable<T> = Pick<T, WritableKeys<T>>;
|
|
43
47
|
type NonReadonly<T> = [
|
|
@@ -53,7 +53,10 @@ export declare const webChatGateway: (_btnCodeDirty?: boolean) => {
|
|
|
53
53
|
flow: {};
|
|
54
54
|
id: string;
|
|
55
55
|
};
|
|
56
|
-
alternativeChannels: {
|
|
56
|
+
alternativeChannels: Record<string, {
|
|
57
|
+
url: string;
|
|
58
|
+
enabled: boolean;
|
|
59
|
+
}>;
|
|
57
60
|
};
|
|
58
61
|
name: string;
|
|
59
62
|
uri: string;
|
|
@@ -5,7 +5,7 @@ export declare const FileServicesAPI: {
|
|
|
5
5
|
next: any;
|
|
6
6
|
}>;
|
|
7
7
|
delete: (id: any) => Promise<any>;
|
|
8
|
-
getScreenRecordingsByUser: (params:
|
|
8
|
+
getScreenRecordingsByUser: (params: unknown) => Promise<{
|
|
9
9
|
items: any;
|
|
10
10
|
next: any;
|
|
11
11
|
}>;
|
|
@@ -13,7 +13,7 @@ export declare const FileServicesAPI: {
|
|
|
13
13
|
userId: any;
|
|
14
14
|
id: any;
|
|
15
15
|
}) => Promise<any>;
|
|
16
|
-
getScreenRecordingsByAgent: (params:
|
|
16
|
+
getScreenRecordingsByAgent: (params: unknown) => Promise<{
|
|
17
17
|
items: any;
|
|
18
18
|
next: any;
|
|
19
19
|
}>;
|
|
@@ -3,7 +3,7 @@ export declare const PdfServicesAPI: {
|
|
|
3
3
|
agentId: any;
|
|
4
4
|
itemInstance: any;
|
|
5
5
|
}) => Promise<any>;
|
|
6
|
-
getList: (params:
|
|
6
|
+
getList: (params: unknown) => Promise<{
|
|
7
7
|
items: any;
|
|
8
8
|
next: any;
|
|
9
9
|
}>;
|
|
@@ -11,7 +11,7 @@ export declare const PdfServicesAPI: {
|
|
|
11
11
|
callId: any;
|
|
12
12
|
itemInstance: any;
|
|
13
13
|
}) => Promise<any>;
|
|
14
|
-
listCallExports: (params:
|
|
14
|
+
listCallExports: (params: unknown) => Promise<{
|
|
15
15
|
items: any;
|
|
16
16
|
next: any;
|
|
17
17
|
}>;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Creates a default response object for list operations
|
|
3
3
|
* @returns Default list response object with empty items array and next=false
|
|
4
4
|
*/
|
|
5
|
-
export declare const getDefaultGetListResponse: (
|
|
5
|
+
export declare const getDefaultGetListResponse: () => {
|
|
6
6
|
items: any[];
|
|
7
7
|
next: boolean;
|
|
8
8
|
};
|
|
@@ -8,8 +8,8 @@ type WritableKeys<T> = {
|
|
|
8
8
|
-readonly [Q in P]: T[P];
|
|
9
9
|
}, P>;
|
|
10
10
|
}[keyof T];
|
|
11
|
-
type UnionToIntersection<U> = (U extends
|
|
12
|
-
type DistributeReadOnlyOverUnions<T> = T extends
|
|
11
|
+
type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
12
|
+
type DistributeReadOnlyOverUnions<T> = T extends unknown ? NonReadonly<T> : never;
|
|
13
13
|
type Writable<T> = Pick<T, WritableKeys<T>>;
|
|
14
14
|
type NonReadonly<T> = [
|
|
15
15
|
T
|
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
import axiosMock from '../../../../tests/mocks/axiosMock';
|
|
2
|
-
|
|
3
|
-
const instanceMock = axiosMock()().default;
|
|
4
|
-
|
|
5
|
-
vi.doMock('../../../defaults/getDefaultInstance/getDefaultInstance.ts', () => ({
|
|
6
|
-
default: () => instanceMock,
|
|
7
|
-
}));
|
|
8
|
-
|
|
9
|
-
describe('UsersAPI', () => {
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
Object.assign(instanceMock, axiosMock()().default);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('correctly computes "getList" method api call', async () => {
|
|
15
|
-
const get = vi.fn(() =>
|
|
16
|
-
Promise.resolve({
|
|
17
|
-
data: {},
|
|
18
|
-
}),
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
instanceMock.get = get;
|
|
22
|
-
|
|
23
|
-
const UsersAPI = (await import('../users.ts')).default;
|
|
24
|
-
|
|
25
|
-
const inputParams = {
|
|
26
|
-
fields: [
|
|
27
|
-
'id',
|
|
28
|
-
'name',
|
|
29
|
-
'vitest',
|
|
30
|
-
],
|
|
31
|
-
};
|
|
32
|
-
const url = '/users?fields=id&fields=name&fields=vitest&page=1&size=10';
|
|
33
|
-
await UsersAPI.getList(inputParams);
|
|
34
|
-
expect(get).toHaveBeenCalledWith(url);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('correctly computes "getList" method output', async () => {
|
|
38
|
-
const output = {
|
|
39
|
-
items: [
|
|
40
|
-
{
|
|
41
|
-
dnd: false,
|
|
42
|
-
id: 1,
|
|
43
|
-
name: '',
|
|
44
|
-
state: true,
|
|
45
|
-
status: '',
|
|
46
|
-
shouldCaseConvert: '',
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
next: true,
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const response = {
|
|
53
|
-
data: {
|
|
54
|
-
items: [
|
|
55
|
-
{
|
|
56
|
-
id: 1,
|
|
57
|
-
should_case_convert: '',
|
|
58
|
-
},
|
|
59
|
-
],
|
|
60
|
-
next: true,
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const get = vi.fn(() => Promise.resolve(response));
|
|
65
|
-
|
|
66
|
-
instanceMock.get = get;
|
|
67
|
-
|
|
68
|
-
const UsersAPI = (await import('../users.ts')).default;
|
|
69
|
-
|
|
70
|
-
expect(await UsersAPI.getList({})).toEqual(output);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('correctly computes "get" method api call', async () => {
|
|
74
|
-
const inputParams = {
|
|
75
|
-
itemId: 1,
|
|
76
|
-
};
|
|
77
|
-
const url = '/users/1';
|
|
78
|
-
|
|
79
|
-
const get = vi.fn(() =>
|
|
80
|
-
Promise.resolve({
|
|
81
|
-
data: {},
|
|
82
|
-
}),
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
instanceMock.get = get;
|
|
86
|
-
|
|
87
|
-
const UsersAPI = (await import('../users.ts')).default;
|
|
88
|
-
|
|
89
|
-
await UsersAPI.get(inputParams);
|
|
90
|
-
expect(get).toHaveBeenCalledWith(url);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('correctly computes "get" method output', async () => {
|
|
94
|
-
const output = {
|
|
95
|
-
id: 1,
|
|
96
|
-
device: {},
|
|
97
|
-
devices: [],
|
|
98
|
-
license: [],
|
|
99
|
-
roles: [],
|
|
100
|
-
variables: [
|
|
101
|
-
{
|
|
102
|
-
key: '',
|
|
103
|
-
value: '',
|
|
104
|
-
},
|
|
105
|
-
],
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
const response = {
|
|
109
|
-
data: {
|
|
110
|
-
id: 1,
|
|
111
|
-
},
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
const get = vi.fn(() => Promise.resolve(response));
|
|
115
|
-
|
|
116
|
-
instanceMock.get = get;
|
|
117
|
-
|
|
118
|
-
const UsersAPI = (await import('../users.ts')).default;
|
|
119
|
-
|
|
120
|
-
expect(await UsersAPI.get({})).toEqual(output);
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it('correctly computes "add" method api call', async () => {
|
|
124
|
-
const input = {
|
|
125
|
-
itemInstance: {
|
|
126
|
-
name: 'test',
|
|
127
|
-
},
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
const body = {
|
|
131
|
-
name: 'test',
|
|
132
|
-
profile: {}, // variables field (?)
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
const url = '/users';
|
|
136
|
-
|
|
137
|
-
const post = vi.fn(() =>
|
|
138
|
-
Promise.resolve({
|
|
139
|
-
data: {},
|
|
140
|
-
}),
|
|
141
|
-
);
|
|
142
|
-
|
|
143
|
-
instanceMock.post = post;
|
|
144
|
-
|
|
145
|
-
const UsersAPI = (await import('../users.ts')).default;
|
|
146
|
-
|
|
147
|
-
await UsersAPI.add(input);
|
|
148
|
-
expect(post).toHaveBeenCalledWith(url, body);
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
it('correctly computes "add" method output', async () => {
|
|
152
|
-
const output = {
|
|
153
|
-
id: 1,
|
|
154
|
-
checkCase: '',
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
const response = {
|
|
158
|
-
data: {
|
|
159
|
-
id: 1,
|
|
160
|
-
check_case: '',
|
|
161
|
-
},
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
const post = vi.fn(() => Promise.resolve(response));
|
|
165
|
-
|
|
166
|
-
instanceMock.post = post;
|
|
167
|
-
|
|
168
|
-
const UsersAPI = (await import('../users.ts')).default;
|
|
169
|
-
|
|
170
|
-
expect(
|
|
171
|
-
await UsersAPI.add({
|
|
172
|
-
itemInstance: {},
|
|
173
|
-
}),
|
|
174
|
-
).toEqual(output);
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it('correctly computes "update" method api call', async () => {
|
|
178
|
-
const input = {
|
|
179
|
-
itemInstance: {
|
|
180
|
-
name: 'test',
|
|
181
|
-
},
|
|
182
|
-
itemId: 1,
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
const body = {
|
|
186
|
-
name: 'test',
|
|
187
|
-
profile: {}, // variables field (?)
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
const url = '/users/1';
|
|
191
|
-
|
|
192
|
-
const put = vi.fn(() =>
|
|
193
|
-
Promise.resolve({
|
|
194
|
-
data: {},
|
|
195
|
-
}),
|
|
196
|
-
);
|
|
197
|
-
|
|
198
|
-
instanceMock.put = put;
|
|
199
|
-
|
|
200
|
-
const UsersAPI = (await import('../users.ts')).default;
|
|
201
|
-
|
|
202
|
-
await UsersAPI.update(input);
|
|
203
|
-
expect(put).toHaveBeenCalledWith(url, body);
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
it('correctly computes "update" method output', async () => {
|
|
207
|
-
const output = {
|
|
208
|
-
id: 1,
|
|
209
|
-
checkCase: '',
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
const response = {
|
|
213
|
-
data: {
|
|
214
|
-
id: 1,
|
|
215
|
-
check_case: '',
|
|
216
|
-
},
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
const put = vi.fn(() => Promise.resolve(response));
|
|
220
|
-
|
|
221
|
-
instanceMock.put = put;
|
|
222
|
-
|
|
223
|
-
const UsersAPI = (await import('../users.ts')).default;
|
|
224
|
-
|
|
225
|
-
expect(
|
|
226
|
-
await UsersAPI.update({
|
|
227
|
-
itemInstance: {},
|
|
228
|
-
itemId: 1,
|
|
229
|
-
}),
|
|
230
|
-
).toEqual(output);
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
it('correctly computes "patch" method api call', async () => {
|
|
234
|
-
const input = {
|
|
235
|
-
changes: {
|
|
236
|
-
name: 'test',
|
|
237
|
-
},
|
|
238
|
-
id: 1,
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
const body = {
|
|
242
|
-
name: 'test',
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
const url = '/users/1';
|
|
246
|
-
|
|
247
|
-
const patch = vi.fn(() =>
|
|
248
|
-
Promise.resolve({
|
|
249
|
-
data: {},
|
|
250
|
-
}),
|
|
251
|
-
);
|
|
252
|
-
|
|
253
|
-
instanceMock.patch = patch;
|
|
254
|
-
|
|
255
|
-
const UsersAPI = (await import('../users.ts')).default;
|
|
256
|
-
|
|
257
|
-
await UsersAPI.patch(input);
|
|
258
|
-
expect(patch).toHaveBeenCalledWith(url, body);
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
it('correctly computes "delete" method api call', async () => {
|
|
262
|
-
const input = {
|
|
263
|
-
id: 1,
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
const url = '/users/1?permanent=true';
|
|
267
|
-
|
|
268
|
-
const _delete = vi.fn(() =>
|
|
269
|
-
Promise.resolve({
|
|
270
|
-
data: {},
|
|
271
|
-
}),
|
|
272
|
-
);
|
|
273
|
-
|
|
274
|
-
instanceMock.delete = _delete;
|
|
275
|
-
|
|
276
|
-
const UsersAPI = (await import('../users.ts')).default;
|
|
277
|
-
|
|
278
|
-
await UsersAPI.delete(input);
|
|
279
|
-
expect(_delete).toHaveBeenCalledWith(url);
|
|
280
|
-
});
|
|
281
|
-
});
|