Skip to content

Commit 82d747f

Browse files
committed
custom upload endpoint testcase
1 parent 7422da4 commit 82d747f

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/upload.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,35 @@ const uploadSuccessResponseObj = {
2626
"fileType": "image"
2727
};
2828

29+
describe("File upload custom endpoint", function () {
30+
var imagekit = new ImageKit({
31+
...initializationParams,
32+
uploadEndpoint: "https://custom-env.imagekit.io/api/v1/files/upload"
33+
});
34+
35+
it('Upload endpoint test case', function (done) {
36+
const fileOptions = {
37+
fileName: "test_file_name",
38+
file: "test_file_content"
39+
};
40+
41+
var callback = sinon.spy();
42+
43+
const scope = nock('https://custom-env.imagekit.io/api')
44+
.post('/v1/files/upload')
45+
.basicAuth({ user: initializationParams.privateKey, pass: '' })
46+
.reply(200, uploadSuccessResponseObj)
47+
48+
imagekit.upload(fileOptions, callback);
49+
50+
setTimeout( () => {
51+
expect(callback.calledOnce).to.be.true;
52+
sinon.assert.calledWith(callback, null, uploadSuccessResponseObj);
53+
done();
54+
},10);
55+
});
56+
});
57+
2958
describe("File upload", function () {
3059
var imagekit = new ImageKit(initializationParams);
3160

0 commit comments

Comments
 (0)