Skip to content

Commit

Permalink
Mock the test that tries to upload a gs file (#394)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-tolosa authored May 31, 2020
1 parent c6b5913 commit 3f361c7
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions test/uploader_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,31 +115,24 @@ describe("uploader", function () {
});

describe("remote urls ", function () {
var writeSpy;
writeSpy = void 0;
beforeEach(function () {
writeSpy = sinon.spy(ClientRequest.prototype, 'write');
});
afterEach(function () {
writeSpy.restore();
});
const mocked = helper.mockTest();
it("should send s3:// URLs to server", function () {
cloudinary.v2.uploader.upload("s3://test/1.jpg", {
tags: UPLOAD_TAGS,
});
sinon.assert.calledWith(writeSpy, sinon.match(helper.uploadParamMatcher('file', "s3://test/1.jpg")));
sinon.assert.calledWith(mocked.write, sinon.match(helper.uploadParamMatcher('file', "s3://test/1.jpg")));
});
it("should send gs:// URLs to server", function () {
cloudinary.v2.uploader.upload("gs://test/1.jpg", {
tags: UPLOAD_TAGS,
});
sinon.assert.calledWith(writeSpy, sinon.match(helper.uploadParamMatcher('file', "gs://test/1.jpg")));
sinon.assert.calledWith(mocked.write, sinon.match(helper.uploadParamMatcher('file', "gs://test/1.jpg")));
});
it("should send ftp:// URLs to server", function () {
cloudinary.v2.uploader.upload("ftp://example.com/1.jpg", {
tags: UPLOAD_TAGS,
});
sinon.assert.calledWith(writeSpy, sinon.match(helper.uploadParamMatcher('file', "ftp://example.com/1.jpg")));
sinon.assert.calledWith(mocked.write, sinon.match(helper.uploadParamMatcher('file', "ftp://example.com/1.jpg")));
});
});

Expand Down

0 comments on commit 3f361c7

Please sign in to comment.