-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: auto_transcription on upload and explicit support (#690)
- Loading branch information
1 parent
7deaf1b
commit 94d21ab
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const sinon = require('sinon'); | ||
const cloudinary = require('../../../../lib/cloudinary'); | ||
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_transcription set to true if requested', () => { | ||
cloudinary.v2.uploader.upload('irrelevant', { auto_transcription: true }); | ||
sinon.assert.calledWith(spy, sinon.match(helper.uploadParamMatcher('auto_transcription', '1'))); | ||
}); | ||
|
||
it('should send a request with auto_transcription config if requested', () => { | ||
cloudinary.v2.uploader.upload('irrelevant', { auto_transcription: { translate: ['pl'] } }); | ||
sinon.assert.calledWith(spy, sinon.match(helper.uploadParamMatcher('auto_transcription', '{"translate":["pl"]}'))); | ||
}); | ||
}); | ||
|
||
describe('explicit', () => { | ||
it('should send a request with auto_transcription set to true if requested', () => { | ||
cloudinary.v2.uploader.explicit('irrelevant', { auto_transcription: true }); | ||
sinon.assert.calledWith(spy, sinon.match(helper.uploadParamMatcher('auto_transcription', '1'))); | ||
}); | ||
|
||
it('should send a request with auto_transcription config if requested', () => { | ||
cloudinary.v2.uploader.explicit('irrelevant', { auto_transcription: { translate: ['pl'] } }); | ||
sinon.assert.calledWith(spy, sinon.match(helper.uploadParamMatcher('auto_transcription', '{"translate":["pl"]}'))); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters