Skip to content

Commit 7deaf1b

Browse files
feat: auto_chaptering on upload and explicit support (#689)
1 parent 61edd35 commit 7deaf1b

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

lib/utils/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,8 @@ function build_upload_params(options) {
416416
accessibility_analysis: utils.as_safe_bool(options.accessibility_analysis),
417417
use_asset_folder_as_public_id_prefix: utils.as_safe_bool(options.use_asset_folder_as_public_id_prefix),
418418
visual_search: utils.as_safe_bool(options.visual_search),
419-
on_success: options.on_success
419+
on_success: options.on_success,
420+
auto_chaptering: utils.as_safe_bool(options.auto_chaptering)
420421
};
421422
return utils.updateable_resource_params(options, params);
422423
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const assert = require('assert');
2+
const sinon = require('sinon');
3+
4+
const cloudinary = require('../../../../lib/cloudinary');
5+
const createTestConfig = require('../../../testUtils/createTestConfig');
6+
const helper = require('../../../spechelper');
7+
const ClientRequest = require('_http_client').ClientRequest;
8+
9+
describe('Uploader', () => {
10+
let spy;
11+
let xhr;
12+
13+
before(() => {
14+
xhr = sinon.useFakeXMLHttpRequest();
15+
spy = sinon.spy(ClientRequest.prototype, 'write');
16+
});
17+
18+
after(() => {
19+
spy.restore();
20+
xhr.restore();
21+
});
22+
23+
describe('upload', () => {
24+
it('should send a request with auto_chaptering set to true if requested', () => {
25+
cloudinary.v2.uploader.upload('irrelevant', { auto_chaptering: true });
26+
sinon.assert.calledWith(spy, sinon.match(helper.uploadParamMatcher('auto_chaptering', '1')));
27+
});
28+
});
29+
30+
describe('explicit', () => {
31+
it('should send a request with auto_chaptering set to true if requested', () => {
32+
cloudinary.v2.uploader.explicit('irrelevant', { auto_chaptering: true });
33+
sinon.assert.calledWith(spy, sinon.match(helper.uploadParamMatcher('auto_chaptering', '1')));
34+
});
35+
});
36+
});

types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ declare module 'cloudinary' {
541541
oauth_token?: string;
542542
use_asset_folder_as_public_id_prefix?: boolean;
543543
regions?: Record<string, [RegionCoordinate, RegionCoordinate, ...Array<RegionCoordinate>]>;
544+
auto_chaptering?: boolean;
544545

545546
[futureKey: string]: any;
546547
}

0 commit comments

Comments
 (0)