Skip to content

Commit 3f361c7

Browse files
Mock the test that tries to upload a gs file (#394)
1 parent c6b5913 commit 3f361c7

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

test/uploader_spec.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,31 +115,24 @@ describe("uploader", function () {
115115
});
116116

117117
describe("remote urls ", function () {
118-
var writeSpy;
119-
writeSpy = void 0;
120-
beforeEach(function () {
121-
writeSpy = sinon.spy(ClientRequest.prototype, 'write');
122-
});
123-
afterEach(function () {
124-
writeSpy.restore();
125-
});
118+
const mocked = helper.mockTest();
126119
it("should send s3:// URLs to server", function () {
127120
cloudinary.v2.uploader.upload("s3://test/1.jpg", {
128121
tags: UPLOAD_TAGS,
129122
});
130-
sinon.assert.calledWith(writeSpy, sinon.match(helper.uploadParamMatcher('file', "s3://test/1.jpg")));
123+
sinon.assert.calledWith(mocked.write, sinon.match(helper.uploadParamMatcher('file', "s3://test/1.jpg")));
131124
});
132125
it("should send gs:// URLs to server", function () {
133126
cloudinary.v2.uploader.upload("gs://test/1.jpg", {
134127
tags: UPLOAD_TAGS,
135128
});
136-
sinon.assert.calledWith(writeSpy, sinon.match(helper.uploadParamMatcher('file', "gs://test/1.jpg")));
129+
sinon.assert.calledWith(mocked.write, sinon.match(helper.uploadParamMatcher('file', "gs://test/1.jpg")));
137130
});
138131
it("should send ftp:// URLs to server", function () {
139132
cloudinary.v2.uploader.upload("ftp://example.com/1.jpg", {
140133
tags: UPLOAD_TAGS,
141134
});
142-
sinon.assert.calledWith(writeSpy, sinon.match(helper.uploadParamMatcher('file', "ftp://example.com/1.jpg")));
135+
sinon.assert.calledWith(mocked.write, sinon.match(helper.uploadParamMatcher('file', "ftp://example.com/1.jpg")));
143136
});
144137
});
145138

0 commit comments

Comments
 (0)