Commit 5a4185bc authored by Justin Ho's avatar Justin Ho

Update const names to be more readable

parent b394ef8d
...@@ -8,13 +8,13 @@ describe('JiraConnect API', () => { ...@@ -8,13 +8,13 @@ describe('JiraConnect API', () => {
let mock; let mock;
let response; let response;
const addPath = 'addPath'; const mockAddPath = 'addPath';
const removePath = 'removePath'; const mockRemovePath = 'removePath';
const namespace = 'namespace'; const mockNamespace = 'namespace';
const jwt = 'jwt'; const mockJwt = 'jwt';
const successResponse = { success: true }; const mockResponse = { success: true };
const tokenSpy = jest.fn().mockReturnValue(jwt); const tokenSpy = jest.fn().mockReturnValue(mockJwt);
window.AP = { window.AP = {
context: { context: {
...@@ -32,44 +32,44 @@ describe('JiraConnect API', () => { ...@@ -32,44 +32,44 @@ describe('JiraConnect API', () => {
}); });
describe('addSubscription', () => { describe('addSubscription', () => {
const makeRequest = () => addSubscription(addPath, namespace); const makeRequest = () => addSubscription(mockAddPath, mockNamespace);
it('returns success response', async () => { it('returns success response', async () => {
jest.spyOn(axios, 'post'); jest.spyOn(axios, 'post');
mock mock
.onPost(addPath, { .onPost(mockAddPath, {
jwt, jwt: mockJwt,
namespace_path: namespace, namespace_path: mockNamespace,
}) })
.replyOnce(httpStatus.OK, successResponse); .replyOnce(httpStatus.OK, mockResponse);
response = await makeRequest(); response = await makeRequest();
expect(tokenSpy).toHaveBeenCalled(); expect(tokenSpy).toHaveBeenCalled();
expect(axios.post).toHaveBeenCalledWith(addPath, { expect(axios.post).toHaveBeenCalledWith(mockAddPath, {
jwt, jwt: mockJwt,
namespace_path: namespace, namespace_path: mockNamespace,
}); });
expect(response.data).toEqual(successResponse); expect(response.data).toEqual(mockResponse);
}); });
}); });
describe('removeSubscription', () => { describe('removeSubscription', () => {
const makeRequest = () => removeSubscription(removePath); const makeRequest = () => removeSubscription(mockRemovePath);
it('returns success response', async () => { it('returns success response', async () => {
jest.spyOn(axios, 'delete'); jest.spyOn(axios, 'delete');
mock.onDelete(removePath).replyOnce(httpStatus.OK, successResponse); mock.onDelete(mockRemovePath).replyOnce(httpStatus.OK, mockResponse);
response = await makeRequest(); response = await makeRequest();
expect(tokenSpy).toHaveBeenCalled(); expect(tokenSpy).toHaveBeenCalled();
expect(axios.delete).toHaveBeenCalledWith(removePath, { expect(axios.delete).toHaveBeenCalledWith(mockRemovePath, {
params: { params: {
jwt, jwt: mockJwt,
}, },
}); });
expect(response.data).toEqual(successResponse); expect(response.data).toEqual(mockResponse);
}); });
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment