Skip to content

Commit

Permalink
fix: clean up unneeded Promise.resolves() (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Ritter authored and zhaoyongjie committed Nov 26, 2021
1 parent e9c2b71 commit e1c635d
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export default class SupersetClientClass {
return Promise.reject({ error: 'Failed to fetch CSRF token' });
}

return Promise.resolve(this.csrfToken);
return this.csrfToken;
});

return this.csrfPromise;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('SupersetClientClass', () => {
return new SupersetClientClass().init().then(() => {
expect(fetchMock.calls(LOGIN_GLOB)).toHaveLength(1);

return Promise.resolve();
return true;
});
});

Expand All @@ -68,7 +68,7 @@ describe('SupersetClientClass', () => {
return new SupersetClientClass({ csrfToken: 'abc' }).init().then(() => {
expect(fetchMock.calls(LOGIN_GLOB)).toHaveLength(0);

return Promise.resolve();
return true;
});
});

Expand All @@ -85,7 +85,7 @@ describe('SupersetClientClass', () => {
expect(fetchMock.calls(LOGIN_GLOB)).toHaveLength(1);
expect(client.csrfToken).not.toBe(initialToken);

return Promise.resolve();
return true;
});
});
});
Expand All @@ -103,7 +103,7 @@ describe('SupersetClientClass', () => {
.catch(error => {
expect(error.status).toBe(403);

return Promise.resolve();
return true;
});
});

Expand All @@ -117,7 +117,7 @@ describe('SupersetClientClass', () => {
.catch(error => {
expect(error).toBeDefined();

return Promise.resolve();
return true;
});
});

Expand All @@ -132,7 +132,7 @@ describe('SupersetClientClass', () => {
.catch(error => {
expect(error).toBeDefined();

return Promise.resolve();
return true;
});
});
});
Expand All @@ -148,7 +148,7 @@ describe('SupersetClientClass', () => {
return client.init().then(() => {
expect(client.isAuthenticated()).toBe(true);

return Promise.resolve();
return true;
});
});

Expand All @@ -175,7 +175,7 @@ describe('SupersetClientClass', () => {
expect(error).toEqual(expect.objectContaining({ error: expect.any(String) }));
expect(client.isAuthenticated()).toBe(false);

return Promise.resolve();
return true;
});
});

Expand All @@ -191,7 +191,7 @@ describe('SupersetClientClass', () => {
.catch(() => {
expect(client.isAuthenticated()).toBe(true);

return Promise.resolve();
return true;
}),
);
});
Expand Down Expand Up @@ -228,7 +228,7 @@ describe('SupersetClientClass', () => {
},
);

return Promise.resolve();
return true;
});
});
});
Expand Down Expand Up @@ -282,7 +282,7 @@ describe('SupersetClientClass', () => {
expect(authSpy).toHaveBeenCalledTimes(5);
authSpy.mockRestore();

return Promise.resolve();
return true;
}),
);
});
Expand All @@ -308,7 +308,7 @@ describe('SupersetClientClass', () => {
expect.objectContaining(clientConfig.headers as Object),
);

return Promise.resolve();
return true;
}),
);
});
Expand All @@ -325,7 +325,7 @@ describe('SupersetClientClass', () => {
]).then(() => {
expect(fetchMock.calls(mockGetUrl)).toHaveLength(2);

return Promise.resolve();
return true;
}),
);
});
Expand All @@ -343,7 +343,7 @@ describe('SupersetClientClass', () => {
expect(fetchMock.calls(mockTextUrl)).toHaveLength(1);
expect(text).toBe(mockTextJsonResponse);

return Promise.resolve();
return true;
})
.catch(throwIfCalled),
)
Expand Down Expand Up @@ -382,7 +382,7 @@ describe('SupersetClientClass', () => {
expect.objectContaining(overrideConfig.headers as Object),
);

return Promise.resolve();
return true;
})
.catch(throwIfCalled),
)
Expand All @@ -402,7 +402,7 @@ describe('SupersetClientClass', () => {
]).then(() => {
expect(fetchMock.calls(mockPostUrl)).toHaveLength(2);

return Promise.resolve();
return true;
}),
);
});
Expand Down Expand Up @@ -434,7 +434,7 @@ describe('SupersetClientClass', () => {
expect.objectContaining(overrideConfig.headers as Object),
);

return Promise.resolve();
return true;
}),
);
});
Expand All @@ -448,7 +448,7 @@ describe('SupersetClientClass', () => {
expect(fetchMock.calls(mockTextUrl)).toHaveLength(1);
expect(text).toBe(mockTextJsonResponse);

return Promise.resolve();
return true;
}),
);
});
Expand All @@ -467,7 +467,7 @@ describe('SupersetClientClass', () => {
expect(formData.get(key)).toBe(JSON.stringify(postPayload[key]));
});

return Promise.resolve();
return true;
}),
);
});
Expand All @@ -485,7 +485,7 @@ describe('SupersetClientClass', () => {
expect(formData.get(key)).toBe(String(postPayload[key]));
});

return Promise.resolve();
return true;
}),
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('callApi()', () => {
expect(fetchMock.calls(mockPutUrl)).toHaveLength(1);
expect(fetchMock.calls(mockPatchUrl)).toHaveLength(1);

return Promise.resolve();
return true;
});
});

Expand Down Expand Up @@ -85,7 +85,7 @@ describe('callApi()', () => {
expect(fetchParams.signal).toBe(mockRequest.signal);
expect(fetchParams.body).toBe(mockRequest.body);

return Promise.resolve();
return true;
});
});
});
Expand All @@ -106,7 +106,7 @@ describe('callApi()', () => {
expect(body.get(key)).toBe(JSON.stringify(postPayload[key]));
});

return Promise.resolve();
return true;
});
});

Expand All @@ -124,7 +124,7 @@ describe('callApi()', () => {
expect(body.get('key')).toBe(JSON.stringify(postPayload.key));
expect(body.get('noValue')).toBeNull();

return Promise.resolve();
return true;
});
});

Expand Down Expand Up @@ -155,7 +155,7 @@ describe('callApi()', () => {
expect(unstringified.get(key)).toBe(String(postPayload[key]));
});

return Promise.resolve();
return true;
});
});
});
Expand All @@ -176,7 +176,7 @@ describe('callApi()', () => {
expect(body.get(key)).toBe(JSON.stringify(postPayload[key]));
});

return Promise.resolve();
return true;
});
});

Expand All @@ -194,7 +194,7 @@ describe('callApi()', () => {
expect(body.get('key')).toBe(JSON.stringify(postPayload.key));
expect(body.get('noValue')).toBeNull();

return Promise.resolve();
return true;
});
});

Expand Down Expand Up @@ -225,7 +225,7 @@ describe('callApi()', () => {
expect(unstringified.get(key)).toBe(String(postPayload[key]));
});

return Promise.resolve();
return true;
});
});
});
Expand All @@ -246,7 +246,7 @@ describe('callApi()', () => {
expect(body.get(key)).toBe(JSON.stringify(postPayload[key]));
});

return Promise.resolve();
return true;
});
});

Expand All @@ -264,7 +264,7 @@ describe('callApi()', () => {
expect(body.get('key')).toBe(JSON.stringify(postPayload.key));
expect(body.get('noValue')).toBeNull();

return Promise.resolve();
return true;
});
});

Expand Down Expand Up @@ -295,7 +295,7 @@ describe('callApi()', () => {
expect(unstringified.get(key)).toBe(String(postPayload[key]));
});

return Promise.resolve();
return true;
});
});
});
Expand All @@ -309,7 +309,7 @@ describe('callApi()', () => {
supersetCache.match(mockCacheUrl).then(cachedResponse => {
expect(cachedResponse).toBeDefined();

return Promise.resolve();
return true;
}),
);
}));
Expand Down Expand Up @@ -347,7 +347,7 @@ describe('callApi()', () => {
expect(calls).toHaveLength(2);
expect(fetchParams.headers).toEqual(expect.objectContaining(headers));

return Promise.resolve();
return true;
});
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe('callApiAndParseWithTimeout()', () => {
(response: Json) => {
expect(response.json).toEqual(expect.objectContaining(mockGetPayload));

return Promise.resolve();
return true;
},
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('parseResponse()', () => {
expect(Object.keys(args)).toEqual(expect.arrayContaining(['response', 'json']));
expect(args.json).toEqual(expect.objectContaining(mockGetPayload));

return Promise.resolve();
return true;
});
});

Expand All @@ -65,7 +65,7 @@ describe('parseResponse()', () => {
expect(error.stack).toBeDefined();
expect(error.message.includes('Unexpected token')).toBe(true);

return Promise.resolve();
return true;
});
});

Expand All @@ -84,7 +84,7 @@ describe('parseResponse()', () => {
expect(Object.keys(args)).toEqual(expect.arrayContaining(['response', 'text']));
expect(args.text).toBe(mockTextJsonResponse);

return Promise.resolve();
return true;
});
});

Expand All @@ -105,7 +105,7 @@ describe('parseResponse()', () => {
expect(fetchMock.calls(mockNoParseUrl)).toHaveLength(1);
expect(response.bodyUsed).toBe(false);

return Promise.resolve();
return true;
});
});

Expand Down

0 comments on commit e1c635d

Please sign in to comment.