diff --git a/lib/utils/index.js b/lib/utils/index.js index 9e808ae0..b317975c 100644 --- a/lib/utils/index.js +++ b/lib/utils/index.js @@ -416,7 +416,8 @@ function build_upload_params(options) { accessibility_analysis: utils.as_safe_bool(options.accessibility_analysis), use_asset_folder_as_public_id_prefix: utils.as_safe_bool(options.use_asset_folder_as_public_id_prefix), visual_search: utils.as_safe_bool(options.visual_search), - on_success: options.on_success + on_success: options.on_success, + auto_chaptering: utils.as_safe_bool(options.auto_chaptering) }; return utils.updateable_resource_params(options, params); } diff --git a/test/integration/api/uploader/auto_chaptering_spec.js b/test/integration/api/uploader/auto_chaptering_spec.js new file mode 100644 index 00000000..54ad7e02 --- /dev/null +++ b/test/integration/api/uploader/auto_chaptering_spec.js @@ -0,0 +1,36 @@ +const assert = require('assert'); +const sinon = require('sinon'); + +const cloudinary = require('../../../../lib/cloudinary'); +const createTestConfig = require('../../../testUtils/createTestConfig'); +const helper = require('../../../spechelper'); +const ClientRequest = require('_http_client').ClientRequest; + +describe('Uploader', () => { + let spy; + let xhr; + + before(() => { + xhr = sinon.useFakeXMLHttpRequest(); + spy = sinon.spy(ClientRequest.prototype, 'write'); + }); + + after(() => { + spy.restore(); + xhr.restore(); + }); + + describe('upload', () => { + it('should send a request with auto_chaptering set to true if requested', () => { + cloudinary.v2.uploader.upload('irrelevant', { auto_chaptering: true }); + sinon.assert.calledWith(spy, sinon.match(helper.uploadParamMatcher('auto_chaptering', '1'))); + }); + }); + + describe('explicit', () => { + it('should send a request with auto_chaptering set to true if requested', () => { + cloudinary.v2.uploader.explicit('irrelevant', { auto_chaptering: true }); + sinon.assert.calledWith(spy, sinon.match(helper.uploadParamMatcher('auto_chaptering', '1'))); + }); + }); +}); diff --git a/types/index.d.ts b/types/index.d.ts index 908ef607..1973cf12 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -541,6 +541,7 @@ declare module 'cloudinary' { oauth_token?: string; use_asset_folder_as_public_id_prefix?: boolean; regions?: Record]>; + auto_chaptering?: boolean; [futureKey: string]: any; }