mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-03 06:11:48 +00:00
Infer redux types when possible
This commit is contained in:
@@ -3,7 +3,7 @@ import { render } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import type { PropsWithChildren, ReactElement } from 'react';
|
||||
import { Provider } from 'react-redux';
|
||||
import type { ShlinkState } from '../../src/container/types';
|
||||
import type { RootState } from '../../src/store';
|
||||
import { setUpStore } from '../../src/store';
|
||||
|
||||
export const renderWithEvents = (element: ReactElement, options?: RenderOptions) => ({
|
||||
@@ -12,7 +12,7 @@ export const renderWithEvents = (element: ReactElement, options?: RenderOptions)
|
||||
});
|
||||
|
||||
export type RenderOptionsWithState = Omit<RenderOptions, 'wrapper'> & {
|
||||
initialState?: Partial<ShlinkState>;
|
||||
initialState?: Partial<RootState>;
|
||||
};
|
||||
|
||||
export const renderWithStore = (
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type { ShlinkApiClient } from '@shlinkio/shlink-js-sdk';
|
||||
import { fromPartial } from '@total-typescript/shoehorn';
|
||||
import type { ShlinkState } from '../../../src/container/types';
|
||||
import type { NonReachableServer, NotFoundServer, RegularServer } from '../../../src/servers/data';
|
||||
import {
|
||||
MAX_FALLBACK_VERSION,
|
||||
@@ -9,6 +8,7 @@ import {
|
||||
selectedServerReducer as reducer,
|
||||
selectServer,
|
||||
} from '../../../src/servers/reducers/selectedServer';
|
||||
import type { RootState } from '../../../src/store';
|
||||
|
||||
describe('selectedServerReducer', () => {
|
||||
const dispatch = vi.fn();
|
||||
@@ -71,7 +71,7 @@ describe('selectedServerReducer', () => {
|
||||
|
||||
it('dispatches error when server is not found', async () => {
|
||||
const id = crypto.randomUUID();
|
||||
const getState = vi.fn(() => fromPartial<ShlinkState>({ servers: {} }));
|
||||
const getState = vi.fn(() => fromPartial<RootState>({ servers: {} }));
|
||||
const expectedSelectedServer: NotFoundServer = { serverNotFound: true };
|
||||
|
||||
await selectServer({ serverId: id, buildShlinkApiClient })(dispatch, getState, {});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { fromPartial } from '@total-typescript/shoehorn';
|
||||
import type { ShlinkState } from '../../../src/container/types';
|
||||
import { migrateDeprecatedSettings } from '../../../src/settings/helpers';
|
||||
import type { RootState } from '../../../src/store';
|
||||
|
||||
describe('settings-helpers', () => {
|
||||
describe('migrateDeprecatedSettings', () => {
|
||||
@@ -9,7 +9,7 @@ describe('settings-helpers', () => {
|
||||
});
|
||||
|
||||
it('updates settings as expected', () => {
|
||||
const state = fromPartial<ShlinkState>({
|
||||
const state = fromPartial<RootState>({
|
||||
settings: {
|
||||
visits: {
|
||||
defaultInterval: 'last180days' as any,
|
||||
|
||||
Reference in New Issue
Block a user