Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mock the test that tries to upload a gs file #394

Merged
merged 1 commit into from
May 31, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions test/uploader_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,31 +114,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