Skip to content

Commit

Permalink
feat: auto_chaptering on upload and explicit support (#689)
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudinary-pkoniu authored Sep 13, 2024
1 parent 61edd35 commit 7deaf1b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
36 changes: 36 additions & 0 deletions test/integration/api/uploader/auto_chaptering_spec.js
Original file line number Diff line number Diff line change
@@ -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')));
});
});
});
1 change: 1 addition & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@ declare module 'cloudinary' {
oauth_token?: string;
use_asset_folder_as_public_id_prefix?: boolean;
regions?: Record<string, [RegionCoordinate, RegionCoordinate, ...Array<RegionCoordinate>]>;
auto_chaptering?: boolean;

[futureKey: string]: any;
}
Expand Down

0 comments on commit 7deaf1b

Please sign in to comment.