2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
2022-11-09 18:20:10 +01:00
|
|
|
import { fireEvent } from '@testing-library/react';
|
|
|
|
import configureMockStore from 'redux-mock-store';
|
|
|
|
import thunk from 'redux-thunk';
|
|
|
|
import mockState from '../../../../test/data/mock-state.json';
|
|
|
|
import { renderWithProvider } from '../../../../test/lib/render-helpers';
|
|
|
|
import AdvancedTab from '.';
|
|
|
|
|
|
|
|
const mockSetAutoLockTimeLimit = jest.fn();
|
|
|
|
const mockSetShowTestNetworks = jest.fn();
|
|
|
|
|
2023-02-03 18:56:44 +01:00
|
|
|
jest.mock('../../../store/actions.ts', () => {
|
2022-11-09 18:20:10 +01:00
|
|
|
return {
|
|
|
|
setAutoLockTimeLimit: () => mockSetAutoLockTimeLimit,
|
|
|
|
setShowTestNetworks: () => mockSetShowTestNetworks,
|
|
|
|
};
|
|
|
|
});
|
2019-05-08 20:57:21 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('AdvancedTab Component', () => {
|
2022-11-09 18:20:10 +01:00
|
|
|
const mockStore = configureMockStore([thunk])(mockState);
|
2019-05-08 20:57:21 +02:00
|
|
|
|
2022-08-09 20:36:32 +02:00
|
|
|
it('should render backup button', () => {
|
2022-11-09 18:20:10 +01:00
|
|
|
const { queryByTestId } = renderWithProvider(<AdvancedTab />, mockStore);
|
|
|
|
const backupButton = queryByTestId('backup-button');
|
|
|
|
expect(backupButton).toBeInTheDocument();
|
2022-08-09 20:36:32 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should render restore button', () => {
|
2022-11-09 18:20:10 +01:00
|
|
|
const { queryByTestId } = renderWithProvider(<AdvancedTab />, mockStore);
|
|
|
|
const restoreFile = queryByTestId('restore-file');
|
|
|
|
expect(restoreFile).toBeInTheDocument();
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2019-09-16 19:11:01 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('should update autoLockTimeLimit', () => {
|
2022-11-09 18:20:10 +01:00
|
|
|
const { queryByTestId } = renderWithProvider(<AdvancedTab />, mockStore);
|
|
|
|
const autoLockoutTime = queryByTestId('auto-lockout-time');
|
|
|
|
const autoLockoutButton = queryByTestId('auto-lockout-button');
|
|
|
|
|
|
|
|
fireEvent.change(autoLockoutTime, { target: { value: 1440 } });
|
|
|
|
|
|
|
|
expect(autoLockoutTime).toHaveValue(1440);
|
|
|
|
|
|
|
|
fireEvent.click(autoLockoutButton);
|
|
|
|
|
|
|
|
expect(mockSetAutoLockTimeLimit).toHaveBeenCalled();
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2021-10-28 21:31:05 +02:00
|
|
|
|
|
|
|
it('should toggle show test networks', () => {
|
2022-11-09 18:20:10 +01:00
|
|
|
const { queryAllByRole } = renderWithProvider(<AdvancedTab />, mockStore);
|
|
|
|
|
2022-12-19 18:46:36 +01:00
|
|
|
const testNetworkToggle = queryAllByRole('checkbox')[3];
|
2022-11-09 18:20:10 +01:00
|
|
|
|
|
|
|
fireEvent.click(testNetworkToggle);
|
|
|
|
|
|
|
|
expect(mockSetShowTestNetworks).toHaveBeenCalled();
|
2021-10-28 21:31:05 +02:00
|
|
|
});
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|