smartling-api-sdk-nodejs 2.3.0 → 2.5.0
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/.scannerwork/report-task.txt +2 -2
- package/api/file-translations/dto/error.ts +7 -0
- package/api/file-translations/dto/language-detection-dto.ts +5 -0
- package/api/file-translations/dto/language-detection-state.ts +5 -0
- package/api/file-translations/dto/language-detection-status-dto.ts +11 -0
- package/api/file-translations/dto/language-dto.ts +6 -0
- package/api/file-translations/dto/mt-state.ts +7 -0
- package/api/file-translations/dto/translation-dto.ts +5 -0
- package/api/file-translations/dto/translation-locale-status-dto.ts +11 -0
- package/api/file-translations/dto/translation-status-dto.ts +12 -0
- package/api/file-translations/dto/uploaded-file-dto.ts +5 -0
- package/api/file-translations/index.ts +114 -0
- package/api/file-translations/params/translate-file-parameters.ts +13 -0
- package/api/file-translations/params/upload-file-parameters.ts +29 -0
- package/api/files/index.ts +1 -1
- package/api/files/params/download-file-all-translations-parameters.ts +1 -7
- package/api/job-batches/dto/batch-list-item-dto.ts +14 -0
- package/api/job-batches/index.ts +13 -0
- package/api/job-batches/params/list-batches-parameters.ts +41 -0
- package/api/jobs/params/create-job-parameters.ts +6 -0
- package/built/api/file-translations/dto/error.d.ts +6 -0
- package/built/api/file-translations/dto/error.js +3 -0
- package/built/api/file-translations/dto/error.js.map +1 -0
- package/built/api/file-translations/dto/language-detection-dto.d.ts +4 -0
- package/built/api/file-translations/dto/language-detection-dto.js +3 -0
- package/built/api/file-translations/dto/language-detection-dto.js.map +1 -0
- package/built/api/file-translations/dto/language-detection-state.d.ts +5 -0
- package/built/api/file-translations/dto/language-detection-state.js +10 -0
- package/built/api/file-translations/dto/language-detection-state.js.map +1 -0
- package/built/api/file-translations/dto/language-detection-status-dto.d.ts +9 -0
- package/built/api/file-translations/dto/language-detection-status-dto.js +3 -0
- package/built/api/file-translations/dto/language-detection-status-dto.js.map +1 -0
- package/built/api/file-translations/dto/language-dto.d.ts +5 -0
- package/built/api/file-translations/dto/language-dto.js +3 -0
- package/built/api/file-translations/dto/language-dto.js.map +1 -0
- package/built/api/file-translations/dto/mt-state.d.ts +7 -0
- package/built/api/file-translations/dto/mt-state.js +12 -0
- package/built/api/file-translations/dto/mt-state.js.map +1 -0
- package/built/api/file-translations/dto/translation-dto.d.ts +4 -0
- package/built/api/file-translations/dto/translation-dto.js +3 -0
- package/built/api/file-translations/dto/translation-dto.js.map +1 -0
- package/built/api/file-translations/dto/translation-locale-status-dto.d.ts +9 -0
- package/built/api/file-translations/dto/translation-locale-status-dto.js +3 -0
- package/built/api/file-translations/dto/translation-locale-status-dto.js.map +1 -0
- package/built/api/file-translations/dto/translation-status-dto.d.ts +10 -0
- package/built/api/file-translations/dto/translation-status-dto.js +3 -0
- package/built/api/file-translations/dto/translation-status-dto.js.map +1 -0
- package/built/api/file-translations/dto/uploaded-file-dto.d.ts +4 -0
- package/built/api/file-translations/dto/uploaded-file-dto.js +3 -0
- package/built/api/file-translations/dto/uploaded-file-dto.js.map +1 -0
- package/built/api/file-translations/index.d.ts +23 -0
- package/built/api/file-translations/index.js +78 -0
- package/built/api/file-translations/index.js.map +1 -0
- package/built/api/file-translations/params/translate-file-parameters.d.ts +5 -0
- package/built/api/file-translations/params/translate-file-parameters.js +16 -0
- package/built/api/file-translations/params/translate-file-parameters.js.map +1 -0
- package/built/api/file-translations/params/upload-file-parameters.d.ts +8 -0
- package/built/api/file-translations/params/upload-file-parameters.js +52 -0
- package/built/api/file-translations/params/upload-file-parameters.js.map +1 -0
- package/built/api/files/index.js +1 -1
- package/built/api/files/index.js.map +1 -1
- package/built/api/files/params/download-file-all-translations-parameters.d.ts +0 -1
- package/built/api/files/params/download-file-all-translations-parameters.js +0 -4
- package/built/api/files/params/download-file-all-translations-parameters.js.map +1 -1
- package/built/api/job-batches/dto/batch-list-item-dto.d.ts +11 -0
- package/built/api/job-batches/dto/batch-list-item-dto.js +3 -0
- package/built/api/job-batches/dto/batch-list-item-dto.js.map +1 -0
- package/built/api/job-batches/index.d.ts +4 -0
- package/built/api/job-batches/index.js +5 -0
- package/built/api/job-batches/index.js.map +1 -1
- package/built/api/job-batches/params/list-batches-parameters.d.ts +10 -0
- package/built/api/job-batches/params/list-batches-parameters.js +33 -0
- package/built/api/job-batches/params/list-batches-parameters.js.map +1 -0
- package/built/api/jobs/params/create-job-parameters.d.ts +1 -0
- package/built/api/jobs/params/create-job-parameters.js +4 -0
- package/built/api/jobs/params/create-job-parameters.js.map +1 -1
- package/built/index.d.ts +2 -0
- package/built/index.js +2 -0
- package/built/index.js.map +1 -1
- package/built/package.json +1 -1
- package/index.ts +2 -0
- package/package.json +1 -1
- package/test/builder.spec.ts +8 -0
- package/test/file-translations.spec.ts +282 -0
- package/test/files.spec.ts +1 -23
- package/test/job-batches.spec.ts +30 -0
- package/test/jobs.spec.ts +3 -2
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import assert from "assert";
|
|
2
|
+
import FormData from "form-data";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import sinon from "sinon";
|
|
5
|
+
import { loggerMock, authMock, responseMock } from "./mock";
|
|
6
|
+
import { SmartlingFileTranslationsApi } from "../api/file-translations";
|
|
7
|
+
import { SmartlingAuthApi } from "../api/auth";
|
|
8
|
+
import { UploadFileParameters } from "../api/file-translations/params/upload-file-parameters";
|
|
9
|
+
import { FileType } from "../api/files/params/file-type";
|
|
10
|
+
import { streamToString } from "./stream-to-string";
|
|
11
|
+
import { TranslateFileParameters } from "../api/file-translations/params/translate-file-parameters";
|
|
12
|
+
|
|
13
|
+
describe("SmartlingFileTranslationsApi class tests.", () => {
|
|
14
|
+
const userAgent = "test_user_agent";
|
|
15
|
+
const accountUid = "testAccountUid";
|
|
16
|
+
const fileUid = "testFileUid";
|
|
17
|
+
const mtUid = "testMtUid";
|
|
18
|
+
const languageDetectionUid = "testLanguageDetectionUid";
|
|
19
|
+
|
|
20
|
+
let fileTranslationsApi: SmartlingFileTranslationsApi;
|
|
21
|
+
let fileTranslationsApiFetchStub;
|
|
22
|
+
let fileTranslationsApiUaStub;
|
|
23
|
+
let responseMockJsonStub;
|
|
24
|
+
|
|
25
|
+
beforeEach(() => {
|
|
26
|
+
fileTranslationsApi = new SmartlingFileTranslationsApi(
|
|
27
|
+
"https://test.com",
|
|
28
|
+
authMock as unknown as SmartlingAuthApi,
|
|
29
|
+
loggerMock
|
|
30
|
+
);
|
|
31
|
+
fileTranslationsApiFetchStub = sinon.stub(fileTranslationsApi, "fetch");
|
|
32
|
+
fileTranslationsApiUaStub = sinon.stub(fileTranslationsApi, "ua");
|
|
33
|
+
responseMockJsonStub = sinon.stub(responseMock, "json");
|
|
34
|
+
|
|
35
|
+
fileTranslationsApiFetchStub.returns(responseMock);
|
|
36
|
+
fileTranslationsApiUaStub.returns(userAgent);
|
|
37
|
+
responseMockJsonStub.returns({
|
|
38
|
+
response: {}
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
afterEach(() => {
|
|
43
|
+
fileTranslationsApiFetchStub.restore();
|
|
44
|
+
fileTranslationsApiUaStub.restore();
|
|
45
|
+
responseMockJsonStub.restore();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe("Methods", () => {
|
|
49
|
+
it("Upload file: from disk", async () => {
|
|
50
|
+
const params = new UploadFileParameters();
|
|
51
|
+
|
|
52
|
+
params
|
|
53
|
+
.setFileType(FileType.XML)
|
|
54
|
+
.setFileFromLocalFilePath("./test/data/file.xml");
|
|
55
|
+
|
|
56
|
+
await fileTranslationsApi.uploadFile(accountUid, params);
|
|
57
|
+
|
|
58
|
+
sinon.assert.calledOnce(fileTranslationsApiFetchStub);
|
|
59
|
+
|
|
60
|
+
const fileTranslationsApiFetchCall = fileTranslationsApiFetchStub.getCall(0);
|
|
61
|
+
|
|
62
|
+
assert.equal(
|
|
63
|
+
fileTranslationsApiFetchCall.args[0],
|
|
64
|
+
`https://test.com/file-translations-api/v2/accounts/${accountUid}/files`
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
assert.equal(
|
|
68
|
+
fileTranslationsApiFetchCall.args[1].method,
|
|
69
|
+
"post"
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
assert.equal(
|
|
73
|
+
fileTranslationsApiFetchCall.args[1].headers.Authorization,
|
|
74
|
+
"test_token_type test_access_token"
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const testFileContent = fs.readFileSync(
|
|
78
|
+
fs.realpathSync("./test/data/file.xml"),
|
|
79
|
+
"utf8"
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const formData = fileTranslationsApiFetchCall.args[1].body as FormData;
|
|
83
|
+
const boundary = formData.getBoundary();
|
|
84
|
+
|
|
85
|
+
assert.equal(fileTranslationsApiFetchCall.args[1].headers["User-Agent"], userAgent);
|
|
86
|
+
assert.equal(fileTranslationsApiFetchCall.args[1].headers["Content-Type"], `multipart/form-data; boundary=${boundary}`);
|
|
87
|
+
|
|
88
|
+
const content = await streamToString(
|
|
89
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
90
|
+
fileTranslationsApiFetchCall.args[1].body._streams[1]
|
|
91
|
+
);
|
|
92
|
+
assert.equal(content, testFileContent);
|
|
93
|
+
|
|
94
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
95
|
+
assert.equal(fileTranslationsApiFetchCall.args[1].body._streams[4], "{\"fileType\":\"XML\"}");
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it("Upload file: as string", async () => {
|
|
99
|
+
const params = new UploadFileParameters();
|
|
100
|
+
|
|
101
|
+
const testFileContent = fs.readFileSync(
|
|
102
|
+
fs.realpathSync("./test/data/file.xml"),
|
|
103
|
+
"utf8"
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
params
|
|
107
|
+
.setFileType(FileType.XML)
|
|
108
|
+
.setFileContent(testFileContent);
|
|
109
|
+
|
|
110
|
+
await fileTranslationsApi.uploadFile(accountUid, params);
|
|
111
|
+
|
|
112
|
+
sinon.assert.calledOnce(fileTranslationsApiFetchStub);
|
|
113
|
+
|
|
114
|
+
const fileTranslationsApiFetchCall = fileTranslationsApiFetchStub.getCall(0);
|
|
115
|
+
|
|
116
|
+
assert.equal(
|
|
117
|
+
fileTranslationsApiFetchCall.args[0],
|
|
118
|
+
`https://test.com/file-translations-api/v2/accounts/${accountUid}/files`
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
assert.equal(
|
|
122
|
+
fileTranslationsApiFetchCall.args[1].method,
|
|
123
|
+
"post"
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
assert.equal(
|
|
127
|
+
fileTranslationsApiFetchCall.args[1].headers.Authorization,
|
|
128
|
+
"test_token_type test_access_token"
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
const formData = fileTranslationsApiFetchCall.args[1].body as FormData;
|
|
132
|
+
const boundary = formData.getBoundary();
|
|
133
|
+
|
|
134
|
+
assert.equal(fileTranslationsApiFetchCall.args[1].headers["User-Agent"], userAgent);
|
|
135
|
+
assert.equal(fileTranslationsApiFetchCall.args[1].headers["Content-Type"], `multipart/form-data; boundary=${boundary}`);
|
|
136
|
+
|
|
137
|
+
const content = await streamToString(
|
|
138
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
139
|
+
fileTranslationsApiFetchCall.args[1].body._streams[1]
|
|
140
|
+
);
|
|
141
|
+
assert.equal(content, testFileContent);
|
|
142
|
+
|
|
143
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
144
|
+
assert.equal(fileTranslationsApiFetchCall.args[1].body._streams[4], "{\"fileType\":\"XML\"}");
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it("Translate file", async () => {
|
|
148
|
+
const params = new TranslateFileParameters();
|
|
149
|
+
|
|
150
|
+
params
|
|
151
|
+
.setSourceLocaleId("en-US")
|
|
152
|
+
.setTargetLocaleIds(["de-DE", "fr-FR"]);
|
|
153
|
+
|
|
154
|
+
await fileTranslationsApi.translateFile(accountUid, fileUid, params);
|
|
155
|
+
|
|
156
|
+
sinon.assert.calledOnceWithExactly(
|
|
157
|
+
fileTranslationsApiFetchStub,
|
|
158
|
+
`https://test.com/file-translations-api/v2/accounts/${accountUid}/files/${fileUid}/mt`,
|
|
159
|
+
{
|
|
160
|
+
method: "post",
|
|
161
|
+
headers: {
|
|
162
|
+
Authorization: "test_token_type test_access_token",
|
|
163
|
+
"Content-Type": "application/json",
|
|
164
|
+
"User-Agent": userAgent
|
|
165
|
+
},
|
|
166
|
+
body: JSON.stringify({
|
|
167
|
+
sourceLocaleId: "en-US",
|
|
168
|
+
targetLocaleIds: ["de-DE", "fr-FR"]
|
|
169
|
+
})
|
|
170
|
+
}
|
|
171
|
+
);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it("Get translation progress", async () => {
|
|
175
|
+
await fileTranslationsApi.getTranslationProgress(accountUid, fileUid, mtUid);
|
|
176
|
+
|
|
177
|
+
sinon.assert.calledOnceWithExactly(
|
|
178
|
+
fileTranslationsApiFetchStub,
|
|
179
|
+
`https://test.com/file-translations-api/v2/accounts/${accountUid}/files/${fileUid}/mt/${mtUid}/status`,
|
|
180
|
+
{
|
|
181
|
+
method: "get",
|
|
182
|
+
headers: {
|
|
183
|
+
Authorization: "test_token_type test_access_token",
|
|
184
|
+
"Content-Type": "application/json",
|
|
185
|
+
"User-Agent": userAgent
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it("Download translated file", async () => {
|
|
192
|
+
const localeId = "de-DE";
|
|
193
|
+
|
|
194
|
+
await fileTranslationsApi.downloadTranslatedFile(accountUid, fileUid, mtUid, localeId);
|
|
195
|
+
|
|
196
|
+
sinon.assert.calledOnceWithExactly(
|
|
197
|
+
fileTranslationsApiFetchStub,
|
|
198
|
+
`https://test.com/file-translations-api/v2/accounts/${accountUid}/files/${fileUid}/mt/${mtUid}/locales/${localeId}/file`,
|
|
199
|
+
{
|
|
200
|
+
method: "get",
|
|
201
|
+
headers: {
|
|
202
|
+
Authorization: "test_token_type test_access_token",
|
|
203
|
+
"Content-Type": "application/json",
|
|
204
|
+
"User-Agent": userAgent
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it("Download translated files", async () => {
|
|
211
|
+
await fileTranslationsApi.downloadTranslatedFiles(accountUid, fileUid, mtUid);
|
|
212
|
+
|
|
213
|
+
sinon.assert.calledOnceWithExactly(
|
|
214
|
+
fileTranslationsApiFetchStub,
|
|
215
|
+
`https://test.com/file-translations-api/v2/accounts/${accountUid}/files/${fileUid}/mt/${mtUid}/locales/all/file/zip`,
|
|
216
|
+
{
|
|
217
|
+
method: "get",
|
|
218
|
+
headers: {
|
|
219
|
+
Authorization: "test_token_type test_access_token",
|
|
220
|
+
"Content-Type": "application/json",
|
|
221
|
+
"User-Agent": userAgent
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
);
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
it("Cancel file translation", async () => {
|
|
228
|
+
await fileTranslationsApi.cancelFileTranslation(accountUid, fileUid, mtUid);
|
|
229
|
+
|
|
230
|
+
sinon.assert.calledOnceWithExactly(
|
|
231
|
+
fileTranslationsApiFetchStub,
|
|
232
|
+
`https://test.com/file-translations-api/v2/accounts/${accountUid}/files/${fileUid}/mt/${mtUid}/cancel`,
|
|
233
|
+
{
|
|
234
|
+
method: "post",
|
|
235
|
+
headers: {
|
|
236
|
+
Authorization: "test_token_type test_access_token",
|
|
237
|
+
"Content-Type": "application/json",
|
|
238
|
+
"User-Agent": userAgent
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
);
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
it("Detect file language", async () => {
|
|
245
|
+
await fileTranslationsApi.detectFileLanguage(accountUid, fileUid);
|
|
246
|
+
|
|
247
|
+
sinon.assert.calledOnceWithExactly(
|
|
248
|
+
fileTranslationsApiFetchStub,
|
|
249
|
+
`https://test.com/file-translations-api/v2/accounts/${accountUid}/files/${fileUid}/language-detection`,
|
|
250
|
+
{
|
|
251
|
+
method: "post",
|
|
252
|
+
headers: {
|
|
253
|
+
Authorization: "test_token_type test_access_token",
|
|
254
|
+
"Content-Type": "application/json",
|
|
255
|
+
"User-Agent": userAgent
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
);
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
it("Get language detection progress", async () => {
|
|
262
|
+
await fileTranslationsApi.getLanguageDetectionProgress(
|
|
263
|
+
accountUid,
|
|
264
|
+
fileUid,
|
|
265
|
+
languageDetectionUid
|
|
266
|
+
);
|
|
267
|
+
|
|
268
|
+
sinon.assert.calledOnceWithExactly(
|
|
269
|
+
fileTranslationsApiFetchStub,
|
|
270
|
+
`https://test.com/file-translations-api/v2/accounts/${accountUid}/files/${fileUid}/language-detection/${languageDetectionUid}/status`,
|
|
271
|
+
{
|
|
272
|
+
method: "get",
|
|
273
|
+
headers: {
|
|
274
|
+
Authorization: "test_token_type test_access_token",
|
|
275
|
+
"Content-Type": "application/json",
|
|
276
|
+
"User-Agent": userAgent
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
);
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
});
|
package/test/files.spec.ts
CHANGED
|
@@ -202,29 +202,7 @@ describe("SmartlingFilesApi class tests.", () => {
|
|
|
202
202
|
sinon.assert.calledOnce(filesApiFetchStub);
|
|
203
203
|
sinon.assert.calledWithExactly(
|
|
204
204
|
filesApiFetchStub,
|
|
205
|
-
`https://test.com/files-api/v2/projects/${projectId}/locales/all/file?retrievalType=published&debugMode=1&fileUri=testFileUri`,
|
|
206
|
-
{
|
|
207
|
-
headers: {
|
|
208
|
-
Authorization: "test_token_type test_access_token",
|
|
209
|
-
"Content-Type": "application/json",
|
|
210
|
-
"User-Agent": "test_user_agent"
|
|
211
|
-
},
|
|
212
|
-
method: "get"
|
|
213
|
-
}
|
|
214
|
-
);
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
it("Download file with zip's name set", async () => {
|
|
218
|
-
const zipFileName = "translations-2.zip";
|
|
219
|
-
params.setZipFileName(zipFileName);
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
await filesApi.downloadFileAllTranslations(projectId, fileUri, params);
|
|
223
|
-
|
|
224
|
-
sinon.assert.calledOnce(filesApiFetchStub);
|
|
225
|
-
sinon.assert.calledWithExactly(
|
|
226
|
-
filesApiFetchStub,
|
|
227
|
-
`https://test.com/files-api/v2/projects/${projectId}/locales/all/file?zipFileName=${zipFileName}&fileUri=testFileUri`,
|
|
205
|
+
`https://test.com/files-api/v2/projects/${projectId}/locales/all/file/zip?retrievalType=published&debugMode=1&fileUri=testFileUri`,
|
|
228
206
|
{
|
|
229
207
|
headers: {
|
|
230
208
|
Authorization: "test_token_type test_access_token",
|
package/test/job-batches.spec.ts
CHANGED
|
@@ -10,6 +10,9 @@ import { FileType } from "../api/files/params/file-type";
|
|
|
10
10
|
import { CancelBatchFileParameters } from "../api/job-batches/params/cancel-batch-file-parameters";
|
|
11
11
|
import { RegisterBatchFileParameters } from "../api/job-batches/params/register-batch-file-parameters";
|
|
12
12
|
import { streamToString } from "./stream-to-string";
|
|
13
|
+
import { ListBatchesParameters } from "../api/job-batches/params/list-batches-parameters";
|
|
14
|
+
import { Order } from "../api/parameters/order";
|
|
15
|
+
import { BatchStatus } from "../api/job-batches/params/batch-status";
|
|
13
16
|
|
|
14
17
|
describe("SmartlingJobBatchesAPI class tests.", () => {
|
|
15
18
|
const projectId = "testProjectId";
|
|
@@ -229,5 +232,32 @@ describe("SmartlingJobBatchesAPI class tests.", () => {
|
|
|
229
232
|
}
|
|
230
233
|
);
|
|
231
234
|
});
|
|
235
|
+
|
|
236
|
+
it("List batches", async () => {
|
|
237
|
+
const params = new ListBatchesParameters();
|
|
238
|
+
const sortByParam = "status";
|
|
239
|
+
params
|
|
240
|
+
.setTranslationJobUid(jobUid)
|
|
241
|
+
.setLimit(100)
|
|
242
|
+
.setOffset(10)
|
|
243
|
+
.setStatus(BatchStatus.COMPLETED)
|
|
244
|
+
.setSort(sortByParam, Order.ASC);
|
|
245
|
+
|
|
246
|
+
await jobBatchesApi.listBatches(projectId, params);
|
|
247
|
+
|
|
248
|
+
sinon.assert.calledOnce(jobBatchesApiFetchStub);
|
|
249
|
+
sinon.assert.calledWithExactly(
|
|
250
|
+
jobBatchesApiFetchStub,
|
|
251
|
+
`https://test.com/job-batches-api/v2/projects/${projectId}/batches?translationJobUid=${jobUid}&limit=100&offset=10&status=${BatchStatus.COMPLETED}&sortBy=${sortByParam}&sortDirection=${(Order.ASC).toLowerCase()}`,
|
|
252
|
+
{
|
|
253
|
+
method: "get",
|
|
254
|
+
headers: {
|
|
255
|
+
Authorization: "test_token_type test_access_token",
|
|
256
|
+
"Content-Type": "application/json",
|
|
257
|
+
"User-Agent": "test_user_agent"
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
);
|
|
261
|
+
});
|
|
232
262
|
});
|
|
233
263
|
});
|
package/test/jobs.spec.ts
CHANGED
|
@@ -52,7 +52,8 @@ describe("SmartlingJobsAPI class tests.", () => {
|
|
|
52
52
|
.setName("Test job")
|
|
53
53
|
.setDescription("Test job description")
|
|
54
54
|
.setDueDate(new Date("2100-12-31T22:00:00.000Z"))
|
|
55
|
-
.setTargetLocaleIds(["pt-PT"])
|
|
55
|
+
.setTargetLocaleIds(["pt-PT"])
|
|
56
|
+
.setCallbackUrl("testCallbackUrl");
|
|
56
57
|
|
|
57
58
|
|
|
58
59
|
await jobApi.createJob(projectId, params);
|
|
@@ -62,7 +63,7 @@ describe("SmartlingJobsAPI class tests.", () => {
|
|
|
62
63
|
jobServiceApiFetchStub,
|
|
63
64
|
`https://test.com/jobs-api/v3/projects/${projectId}/jobs`,
|
|
64
65
|
{
|
|
65
|
-
body: "{\"jobName\":\"Test job\",\"description\":\"Test job description\",\"dueDate\":\"2100-12-31T22:00:00.000Z\",\"targetLocaleIds\":[\"pt-PT\"]}",
|
|
66
|
+
body: "{\"jobName\":\"Test job\",\"description\":\"Test job description\",\"dueDate\":\"2100-12-31T22:00:00.000Z\",\"targetLocaleIds\":[\"pt-PT\"],\"callbackUrl\":\"testCallbackUrl\"}",
|
|
66
67
|
headers: {
|
|
67
68
|
Authorization: "test_token_type test_access_token",
|
|
68
69
|
"Content-Type": "application/json",
|