Removed no longer needed constants

This commit is contained in:
Alejandro Celaya 2019-04-19 12:54:56 +02:00
parent 33d67cbe3d
commit ba3189fd46
5 changed files with 6 additions and 12 deletions

View file

@ -19,7 +19,6 @@ describe('<App />', () => {
it('renders app main routes', () => { it('renders app main routes', () => {
const routes = wrapper.find(Route); const routes = wrapper.find(Route);
const expectedRoutesCount = 4;
const expectedPaths = [ const expectedPaths = [
'/server/create', '/server/create',
'/', '/',
@ -27,7 +26,7 @@ describe('<App />', () => {
]; ];
expect.assertions(expectedPaths.length + 1); expect.assertions(expectedPaths.length + 1);
expect(routes).toHaveLength(expectedRoutesCount); expect(routes).toHaveLength(4);
expectedPaths.forEach((path, index) => { expectedPaths.forEach((path, index) => {
expect(routes.at(index).prop('path')).toEqual(path); expect(routes.at(index).prop('path')).toEqual(path);
}); });

View file

@ -16,9 +16,8 @@ describe('<AsideMenu />', () => {
it('contains links to different sections', () => { it('contains links to different sections', () => {
const links = wrapped.find(NavLink); const links = wrapped.find(NavLink);
const expectedLength = 3;
expect(links).toHaveLength(expectedLength); expect(links).toHaveLength(3);
links.forEach((link) => expect(link.prop('to')).toContain('abc123')); links.forEach((link) => expect(link.prop('to')).toContain('abc123'));
}); });

View file

@ -49,7 +49,6 @@ describe('tagDeleteReducer', () => {
afterEach(() => dispatch.mockReset()); afterEach(() => dispatch.mockReset());
it('calls API on success', async () => { it('calls API on success', async () => {
const expectedDispatchCalls = 2;
const tag = 'foo'; const tag = 'foo';
const apiClientMock = createApiClientMock(Promise.resolve()); const apiClientMock = createApiClientMock(Promise.resolve());
const dispatchable = deleteTag(() => apiClientMock)(tag); const dispatchable = deleteTag(() => apiClientMock)(tag);
@ -59,13 +58,12 @@ describe('tagDeleteReducer', () => {
expect(apiClientMock.deleteTags).toHaveBeenCalledTimes(1); expect(apiClientMock.deleteTags).toHaveBeenCalledTimes(1);
expect(apiClientMock.deleteTags).toHaveBeenNthCalledWith(1, [ tag ]); expect(apiClientMock.deleteTags).toHaveBeenNthCalledWith(1, [ tag ]);
expect(dispatch).toHaveBeenCalledTimes(expectedDispatchCalls); expect(dispatch).toHaveBeenCalledTimes(2);
expect(dispatch).toHaveBeenNthCalledWith(1, { type: DELETE_TAG_START }); expect(dispatch).toHaveBeenNthCalledWith(1, { type: DELETE_TAG_START });
expect(dispatch).toHaveBeenNthCalledWith(2, { type: DELETE_TAG }); expect(dispatch).toHaveBeenNthCalledWith(2, { type: DELETE_TAG });
}); });
it('throws on error', async () => { it('throws on error', async () => {
const expectedDispatchCalls = 2;
const error = 'Error'; const error = 'Error';
const tag = 'foo'; const tag = 'foo';
const apiClientMock = createApiClientMock(Promise.reject(error)); const apiClientMock = createApiClientMock(Promise.reject(error));
@ -80,7 +78,7 @@ describe('tagDeleteReducer', () => {
expect(apiClientMock.deleteTags).toHaveBeenCalledTimes(1); expect(apiClientMock.deleteTags).toHaveBeenCalledTimes(1);
expect(apiClientMock.deleteTags).toHaveBeenNthCalledWith(1, [ tag ]); expect(apiClientMock.deleteTags).toHaveBeenNthCalledWith(1, [ tag ]);
expect(dispatch).toHaveBeenCalledTimes(expectedDispatchCalls); expect(dispatch).toHaveBeenCalledTimes(2);
expect(dispatch).toHaveBeenNthCalledWith(1, { type: DELETE_TAG_START }); expect(dispatch).toHaveBeenNthCalledWith(1, { type: DELETE_TAG_START });
expect(dispatch).toHaveBeenNthCalledWith(2, { type: DELETE_TAG_ERROR }); expect(dispatch).toHaveBeenNthCalledWith(2, { type: DELETE_TAG_ERROR });
}); });

View file

@ -59,7 +59,6 @@ describe('tagEditReducer', () => {
}); });
it('calls API on success', async () => { it('calls API on success', async () => {
const expectedDispatchCalls = 2;
const oldName = 'foo'; const oldName = 'foo';
const newName = 'bar'; const newName = 'bar';
const color = '#ff0000'; const color = '#ff0000';
@ -74,7 +73,7 @@ describe('tagEditReducer', () => {
expect(colorGenerator.setColorForKey).toHaveBeenCalledTimes(1); expect(colorGenerator.setColorForKey).toHaveBeenCalledTimes(1);
expect(colorGenerator.setColorForKey).toHaveBeenCalledWith(newName, color); expect(colorGenerator.setColorForKey).toHaveBeenCalledWith(newName, color);
expect(dispatch).toHaveBeenCalledTimes(expectedDispatchCalls); expect(dispatch).toHaveBeenCalledTimes(2);
expect(dispatch).toHaveBeenNthCalledWith(1, { type: EDIT_TAG_START }); expect(dispatch).toHaveBeenNthCalledWith(1, { type: EDIT_TAG_START });
expect(dispatch).toHaveBeenNthCalledWith(2, { type: EDIT_TAG, oldName, newName }); expect(dispatch).toHaveBeenNthCalledWith(2, { type: EDIT_TAG, oldName, newName });
}); });

View file

@ -76,9 +76,8 @@ describe('<ShortUrlVisits />', () => {
const wrapper = createComponent({ loading: false, error: false, visits: [{}, {}, {}] }); const wrapper = createComponent({ loading: false, error: false, visits: [{}, {}, {}] });
const graphs = wrapper.find(GraphCard); const graphs = wrapper.find(GraphCard);
const sortableBarGraphs = wrapper.find(SortableBarGraph); const sortableBarGraphs = wrapper.find(SortableBarGraph);
const expectedGraphsCount = 5;
expect(graphs.length + sortableBarGraphs.length).toEqual(expectedGraphsCount); expect(graphs.length + sortableBarGraphs.length).toEqual(5);
}); });
it('reloads visits when selected dates change', () => { it('reloads visits when selected dates change', () => {