Skip to content

Commit

Permalink
chore(deps): Remove history dependency (#648)
Browse files Browse the repository at this point in the history
* fix(deps): update dependency axios to v1

* Use new adapter setting

See axios/axios#5277

* Fix tests

* Remove unnecessary transform

* chore(deps): Remove history dependency

* chore: update tests to remove `history`

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Afonso Jorge Ramos <afonsojorgeramos@gmail.com>
  • Loading branch information
3 people committed Oct 24, 2023
1 parent 25f747d commit ce9d7a8
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 76 deletions.
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -100,7 +100,6 @@
"date-fns": "2.30.0",
"electron-updater": "6.1.4",
"final-form": "4.20.10",
"history": "4.10.1",
"menubar": "9.3.0",
"nprogress": "0.2.0",
"react": "18.2.0",
Expand Down
30 changes: 0 additions & 30 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions src/components/Sidebar.test.tsx
@@ -1,7 +1,5 @@
import { fireEvent, render, screen } from '@testing-library/react';
import { createMemoryHistory } from 'history';
import * as React from 'react';
import { Router } from 'react-router';
import { MemoryRouter } from 'react-router-dom';
import * as TestRenderer from 'react-test-renderer';

Expand All @@ -20,7 +18,6 @@ jest.mock('react-router-dom', () => ({

describe('components/Sidebar.tsx', () => {
const fetchNotifications = jest.fn();
const history = createMemoryHistory();

beforeEach(() => {
fetchNotifications.mockReset();
Expand Down Expand Up @@ -81,9 +78,9 @@ describe('components/Sidebar.tsx', () => {
it('go to the settings route', () => {
const { getByLabelText } = render(
<AppContext.Provider value={{ isLoggedIn: true, notifications: [] }}>
<Router location={history.location} navigator={history}>
<MemoryRouter>
<Sidebar />
</Router>
</MemoryRouter>
</AppContext.Provider>,
);
fireEvent.click(getByLabelText('Settings'));
Expand Down
16 changes: 6 additions & 10 deletions src/routes/Login.test.tsx
@@ -1,8 +1,6 @@
import React from 'react';
import TestRenderer from 'react-test-renderer';
import { Router } from 'react-router';
import { MemoryRouter } from 'react-router-dom';
import { createMemoryHistory } from 'history';
import { render, fireEvent } from '@testing-library/react';

const { ipcRenderer } = require('electron');
Expand All @@ -17,8 +15,6 @@ jest.mock('react-router-dom', () => ({
}));

describe('routes/Login.tsx', () => {
const history = createMemoryHistory();

beforeEach(() => {
mockNavigate.mockReset();
jest.spyOn(ipcRenderer, 'send');
Expand All @@ -37,17 +33,17 @@ describe('routes/Login.tsx', () => {
it('should redirect to notifications once logged in', () => {
const { rerender } = render(
<AppContext.Provider value={{ isLoggedIn: false }}>
<Router location={history.location} navigator={history}>
<MemoryRouter>
<LoginRoute />
</Router>
</MemoryRouter>
</AppContext.Provider>,
);

rerender(
<AppContext.Provider value={{ isLoggedIn: true }}>
<Router location={history.location} navigator={history}>
<MemoryRouter>
<LoginRoute />
</Router>
</MemoryRouter>
</AppContext.Provider>,
);

Expand All @@ -58,9 +54,9 @@ describe('routes/Login.tsx', () => {

it('should navigate to login with github enterprise', () => {
const { getByLabelText } = render(
<Router location={history.location} navigator={history}>
<MemoryRouter>
<LoginRoute />
</Router>,
</MemoryRouter>,
);

fireEvent.click(getByLabelText('Login with GitHub Enterprise'));
Expand Down
16 changes: 6 additions & 10 deletions src/routes/LoginEnterprise.test.tsx
@@ -1,9 +1,7 @@
import * as React from 'react';
import * as TestRenderer from 'react-test-renderer';
import { fireEvent, render } from '@testing-library/react';
import { Router } from 'react-router';
import { MemoryRouter } from 'react-router-dom';
import { createMemoryHistory } from 'history';

const { ipcRenderer } = require('electron');

Expand All @@ -19,8 +17,6 @@ jest.mock('react-router-dom', () => ({
}));

describe('routes/LoginEnterprise.js', () => {
const history = createMemoryHistory();

const mockAccounts: AuthState = {
enterpriseAccounts: [],
user: null,
Expand All @@ -47,9 +43,9 @@ describe('routes/LoginEnterprise.js', () => {
it('let us go back', () => {
const { getByLabelText } = render(
<AppContext.Provider value={{ accounts: mockAccounts }}>
<Router location={history.location} navigator={history}>
<MemoryRouter>
<LoginEnterpriseRoute />
</Router>
</MemoryRouter>
</AppContext.Provider>,
);

Expand Down Expand Up @@ -86,9 +82,9 @@ describe('routes/LoginEnterprise.js', () => {
it('should receive a logged-in enterprise account', () => {
const { rerender } = render(
<AppContext.Provider value={{ accounts: mockAccounts }}>
<Router location={history.location} navigator={history}>
<MemoryRouter>
<LoginEnterpriseRoute />
</Router>
</MemoryRouter>
</AppContext.Provider>,
);

Expand All @@ -101,9 +97,9 @@ describe('routes/LoginEnterprise.js', () => {
},
}}
>
<Router location={history.location} navigator={history}>
<MemoryRouter>
<LoginEnterpriseRoute />
</Router>
</MemoryRouter>
</AppContext.Provider>,
);

Expand Down
19 changes: 8 additions & 11 deletions src/routes/LoginWithToken.test.tsx
@@ -1,9 +1,7 @@
import React from 'react';
import TestRenderer from 'react-test-renderer';
import { act, fireEvent, render, waitFor } from '@testing-library/react';
import { Router } from 'react-router';
import { MemoryRouter } from 'react-router-dom';
import { createMemoryHistory } from 'history';
import { shell } from 'electron';

import { AppContext } from '../context/App';
Expand All @@ -16,7 +14,6 @@ jest.mock('react-router-dom', () => ({
}));

describe('routes/LoginWithToken.js', () => {
const history = createMemoryHistory();
const openExternalMock = jest.spyOn(shell, 'openExternal');

const mockValidateToken = jest.fn();
Expand All @@ -43,9 +40,9 @@ describe('routes/LoginWithToken.js', () => {

it('let us go back', () => {
const { getByLabelText } = render(
<Router location={history.location} navigator={history}>
<MemoryRouter>
<LoginWithToken />
</Router>,
</MemoryRouter>,
);

fireEvent.click(getByLabelText('Go Back'));
Expand Down Expand Up @@ -77,9 +74,9 @@ describe('routes/LoginWithToken.js', () => {
it("should click on the 'personal access tokens' link and open the browser", async () => {
const { getByText } = render(
<AppContext.Provider value={{ validateToken: mockValidateToken }}>
<Router location={history.location} navigator={history}>
<MemoryRouter>
<LoginWithToken />
</Router>
</MemoryRouter>
</AppContext.Provider>,
);

Expand All @@ -93,9 +90,9 @@ describe('routes/LoginWithToken.js', () => {

const { getByLabelText, getByTitle } = render(
<AppContext.Provider value={{ validateToken: mockValidateToken }}>
<Router location={history.location} navigator={history}>
<MemoryRouter>
<LoginWithToken />
</Router>
</MemoryRouter>
</AppContext.Provider>,
);

Expand All @@ -119,9 +116,9 @@ describe('routes/LoginWithToken.js', () => {

const { getByLabelText, getByTitle } = render(
<AppContext.Provider value={{ validateToken: mockValidateToken }}>
<Router location={history.location} navigator={history}>
<MemoryRouter>
<LoginWithToken />
</Router>
</MemoryRouter>
</AppContext.Provider>,
);

Expand Down
15 changes: 6 additions & 9 deletions src/routes/Settings.test.tsx
@@ -1,9 +1,7 @@
import React from 'react';
import TestRenderer, { act } from 'react-test-renderer';
import { render, fireEvent } from '@testing-library/react';
import { Router } from 'react-router';
import { MemoryRouter } from 'react-router-dom';
import { createMemoryHistory } from 'history';

const { ipcRenderer } = require('electron');

Expand All @@ -18,7 +16,6 @@ jest.mock('react-router-dom', () => ({
}));

describe('routes/Settings.tsx', () => {
const history = createMemoryHistory();
const updateSetting = jest.fn();

beforeEach(() => {
Expand Down Expand Up @@ -50,9 +47,9 @@ describe('routes/Settings.tsx', () => {
<AppContext.Provider
value={{ settings: mockSettings, logout: logoutMock }}
>
<Router location={history.location} navigator={history}>
<MemoryRouter>
<SettingsRoute />
</Router>
</MemoryRouter>
</AppContext.Provider>,
);

Expand All @@ -74,9 +71,9 @@ describe('routes/Settings.tsx', () => {
await act(async () => {
const { getByLabelText: getByLabelTextLocal } = render(
<AppContext.Provider value={{ settings: mockSettings }}>
<Router location={history.location} navigator={history}>
<MemoryRouter>
<SettingsRoute />
</Router>
</MemoryRouter>
</AppContext.Provider>,
);

Expand Down Expand Up @@ -222,9 +219,9 @@ describe('routes/Settings.tsx', () => {
await act(async () => {
const { getByLabelText: getByLabelTextLocal } = render(
<AppContext.Provider value={{ settings: mockSettings }}>
<Router location={history.location} navigator={history}>
<MemoryRouter>
<SettingsRoute />
</Router>
</MemoryRouter>
</AppContext.Provider>,
);
getByLabelText = getByLabelTextLocal;
Expand Down

0 comments on commit ce9d7a8

Please sign in to comment.