diff --git a/lib/QuipProcessor.js b/lib/QuipProcessor.js
index dd5283e..1277cff 100644
--- a/lib/QuipProcessor.js
+++ b/lib/QuipProcessor.js
@@ -261,14 +261,18 @@ class QuipProcessor {
threadId: quipThread.thread.id,
blobId: file.hash
};
-
- if(Mime.getType(file.name).startsWith('image/')) {
+ const mimeType = Mime.getType(file.name);
+ if(mimeType && mimeType.startsWith('image/')) {
//image
const imageHtml = `
`;
text += await this._processFile(imageHtml, fileMatch, path, this.options.embeddedImages);
} else {
//file
- const fileHtml = `
${file.name}
`;
+ let fileName = file.name;
+ if(!fileName) {
+ fileName = file.hash;
+ }
+ const fileHtml = `
${fileName}
`;
text += await this._processFile(fileHtml, fileMatch, path);
}
diff --git a/lib/__tests__/QuipProcessor.test.js b/lib/__tests__/QuipProcessor.test.js
index 7f874e4..034917a 100644
--- a/lib/__tests__/QuipProcessor.test.js
+++ b/lib/__tests__/QuipProcessor.test.js
@@ -903,10 +903,10 @@ describe('methods tests', () => {
quipProcessor._processFile = jest.fn();
quipProcessor._processFile.mockImplementation((html, fileMatch) => {
- if(fileMatch.blobId === '1c2EXOl1sx04g5_hPNmt1A') {
- return Promise.resolve(html + 'PROCESSED-FILE');
- }
- if(fileMatch.blobId === 'sVhMwHaxsgiwmfMi4au1Zg') {
+ if(['1c2EXOl1sx04g5_hPNmt1A',
+ 'sVhMwHaxsgiwmfMi4au1Zg',
+ '1c2EXOl1sx04g5_hPNmt1A222',
+ 'sVhMwHaxsgiwmfMi4au1Zg111'].includes(fileMatch.blobId)) {
return Promise.resolve(html + 'PROCESSED-FILE');
}
if(fileMatch.blobId === 'Ak5BJnkWubPxpIm4dtlWmg') {
diff --git a/lib/__tests__/QuipService.test.js b/lib/__tests__/QuipService.test.js
index 1169c72..617ddcd 100644
--- a/lib/__tests__/QuipService.test.js
+++ b/lib/__tests__/QuipService.test.js
@@ -31,6 +31,11 @@ response200Blob.blob = jest.fn(() => blob);
const quipService = new QuipService('###TOKEN###', 'http://quip.com');
+beforeEach(() => {
+ quipService.stats.query_count = 0;
+ quipService.querries503 = new Map();
+});
+
test('constructor tests', async () => {
expect(quipService.accessToken).toBe('###TOKEN###');
expect(quipService.apiURL).toBe('http://quip.com');
@@ -38,7 +43,6 @@ test('constructor tests', async () => {
});
test('_apiCall response with 503 code', async () => {
- quipService.stats.query_count = 0;
fetch.mockReturnValue(Promise.resolve(response200)).mockReturnValueOnce(Promise.resolve(response503));
const res = await quipService._apiCall('/someURL');
expect(res.data).toBe(123456);
@@ -46,7 +50,6 @@ test('_apiCall response with 503 code', async () => {
});
test('_apiCall response with 503 code more than 10 times', async () => {
- quipService.stats.query_count = 0;
fetch.mockReturnValue(Promise.resolve(response503));
const res = await quipService._apiCall('/someURL');
expect(res).toBe(undefined);
@@ -69,7 +72,6 @@ test('_apiCall: fetch with exeption', async () => {
});
test('_apiCallBlob response with 503 code', async () => {
- quipService.stats.query_count = 0;
fetch.mockReturnValue(Promise.resolve(response200Blob)).mockReturnValueOnce(Promise.resolve(response503));
const res = await quipService._apiCallBlob('/someURL');
expect(res).toBe(blob);
@@ -77,7 +79,6 @@ test('_apiCallBlob response with 503 code', async () => {
});
test('_apiCallBlob response with 503 code more than 10 times', async () => {
- quipService.stats.query_count = 0;
fetch.mockReturnValue(Promise.resolve(response503));
const res = await quipService._apiCallBlob('/someURL');
expect(res).toBe(undefined);
diff --git a/lib/__tests__/__snapshots__/QuipProcessor.test.js.snap b/lib/__tests__/__snapshots__/QuipProcessor.test.js.snap
index 3b0bc2b..4c48f20 100644
--- a/lib/__tests__/__snapshots__/QuipProcessor.test.js.snap
+++ b/lib/__tests__/__snapshots__/QuipProcessor.test.js.snap
@@ -6,5 +6,5 @@ exports[`methods tests _getThreadMessagesHtml thread with messages 1`] = `