Skip to content

Commit 3bbe861

Browse files
committed
promise test cases for one API
1 parent 0723e8b commit 3bbe861

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests/cache.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,21 @@ describe("Cache purge API", function () {
107107
done();
108108
}, 50);
109109
});
110+
111+
it('Purge cache promise', async function () {
112+
var requestId = "sdfdsfksjfldsjfjsdf";
113+
114+
const scope = nock('https://api.imagekit.io')
115+
.get(`/v1/files/purge/${requestId}`)
116+
.basicAuth({ user: initializationParams.privateKey, pass: '' })
117+
.reply(200, dummyAPISuccessResponse)
118+
119+
var callback = sinon.spy();
120+
121+
var response = await imagekit.getPurgeCacheStatus(requestId);
122+
expect(response).to.be.deep.equal(dummyAPISuccessResponse);
123+
return Promise.resolve();
124+
});
110125
});
111126

112127
describe("Error callbacks", function () {
@@ -146,6 +161,26 @@ describe("Cache purge API", function () {
146161
done();
147162
}, 50);
148163
});
164+
165+
it('Purge cache promise', async function () {
166+
var requestId = "sdfdsfksjfldsjfjsdf";
167+
168+
const scope = nock('https://api.imagekit.io')
169+
.get(`/v1/files/purge/${requestId}`)
170+
.basicAuth({ user: initializationParams.privateKey, pass: '' })
171+
.reply(500, dummyAPIErrorResponse)
172+
173+
var callback = sinon.spy();
174+
175+
try {
176+
await imagekit.getPurgeCacheStatus(requestId);
177+
} catch(ex) {
178+
expect(ex).to.be.deep.equal(dummyAPIErrorResponse);
179+
return Promise.resolve();
180+
}
181+
182+
return Promise.reject();
183+
});
149184
});
150185
});
151186

0 commit comments

Comments
 (0)