Skip to content

Commit 11239de

Browse files
committed
fix: restore test compatibility after root entry cleanup
1 parent b8c35a7 commit 11239de

9 files changed

Lines changed: 50 additions & 35 deletions

File tree

packages/reactant-router-dom/src/generatePath.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@ const compilePath = (path: string) => {
1818
return generator;
1919
};
2020

21-
export const generatePath: typeof ReactRouterDom.generatePath = (
22-
path = '/',
23-
params = {}
21+
export const generatePath: typeof ReactRouterDom.generatePath = <S extends string>(
22+
path: S = '/' as S,
23+
params?: ReactRouterDom.ExtractRouteParams<S, string | number | boolean>
2424
) => {
25-
return path === '/' ? path : compilePath(path)(params, { pretty: true });
25+
const nextParams =
26+
params ??
27+
({} as ReactRouterDom.ExtractRouteParams<S, string | number | boolean>);
28+
29+
return path === '/' ? path : compilePath(path)(nextParams, { pretty: true });
2630
};

packages/reactant-share/test/case.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,11 @@
33
/* eslint-disable @typescript-eslint/ban-ts-comment */
44
/* eslint-disable prefer-destructuring */
55
/* eslint-disable @typescript-eslint/no-empty-function */
6+
import { injectable, state, action, ViewModule } from 'reactant';
67
import {
78
createSharedApp,
8-
injectable,
9-
state,
10-
action,
119
delegate,
1210
mockPairTransports,
13-
ViewModule,
1411
PortDetector,
1512
fork,
1613
} from '..';

packages/reactant-share/test/checkPatches.test.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
/* eslint-disable prefer-const */
22
/* eslint-disable @typescript-eslint/no-explicit-any */
33
import React from 'react';
4-
import { unmountComponentAtNode, render } from 'reactant-web';
5-
import { act } from '../../../scripts/jest/act';
64
import {
75
injectable,
86
state,
97
action,
108
ViewModule,
119
useConnector,
1210
subscribe,
11+
optional,
12+
} from 'reactant';
13+
import { unmountComponentAtNode, render } from 'reactant-web';
14+
import { act } from '../../../scripts/jest/act';
15+
import {
1316
createSharedApp,
1417
delegate,
1518
PortDetector,
16-
optional,
1719
mockPairTransports,
1820
} from '..';
1921

packages/reactant-share/test/coworker.test.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
/* eslint-disable no-promise-executor-return */
22
import React from 'react';
3-
import { unmountComponentAtNode, render } from 'reactant-web';
4-
import { act } from '../../../scripts/jest/act';
53
import {
64
injectable,
75
state,
86
action,
97
ViewModule,
108
useConnector,
119
subscribe,
10+
optional,
11+
} from 'reactant';
12+
import { unmountComponentAtNode, render } from 'reactant-web';
13+
import { act } from '../../../scripts/jest/act';
14+
import {
1215
createSharedApp,
1316
delegate,
1417
PortDetector,
15-
optional,
1618
mockPairTransports,
1719
fork,
1820
Coworker,

packages/reactant-share/test/createTransport.test.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,22 @@
22
/* eslint-disable no-promise-executor-return */
33
/* eslint-disable @typescript-eslint/ban-ts-comment */
44
import React from 'react';
5-
import { unmountComponentAtNode, render } from 'reactant-web';
6-
import { BroadcastChannel } from 'broadcast-channel';
7-
import { act } from '../../../scripts/jest/act';
85
import {
96
injectable,
107
state,
118
action,
129
ViewModule,
1310
useConnector,
1411
subscribe,
12+
optional,
13+
} from 'reactant';
14+
import { unmountComponentAtNode, render } from 'reactant-web';
15+
import { BroadcastChannel } from 'broadcast-channel';
16+
import { act } from '../../../scripts/jest/act';
17+
import {
1518
createSharedApp,
1619
delegate,
1720
PortDetector,
18-
optional,
1921
} from '..';
2022

2123
const mockBroadcastChannels: MockBroadcastChannel[] = [];

packages/reactant-share/test/index.test.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
/* eslint-disable no-promise-executor-return */
22
import React from 'react';
3-
import { unmountComponentAtNode, render } from 'reactant-web';
4-
import { act } from '../../../scripts/jest/act';
5-
import { LastAction } from 'reactant-last-action';
63
import {
74
injectable,
85
state,
96
action,
107
ViewModule,
118
useConnector,
129
subscribe,
10+
optional,
11+
} from 'reactant';
12+
import { unmountComponentAtNode, render } from 'reactant-web';
13+
import { act } from '../../../scripts/jest/act';
14+
import { LastAction } from 'reactant-last-action';
15+
import {
1316
createSharedApp,
1417
delegate,
1518
PortDetector,
16-
optional,
1719
mockPairTransports,
1820
fork,
1921
} from '..';

packages/reactant-share/test/isolate.test.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
/* eslint-disable no-promise-executor-return */
22
import React from 'react';
3-
import { unmountComponentAtNode, render } from 'reactant-web';
4-
import { act } from '../../../scripts/jest/act';
5-
import { LastAction } from 'reactant-last-action';
63
import {
74
injectable,
85
state,
96
action,
107
ViewModule,
118
useConnector,
129
subscribe,
10+
optional,
11+
} from 'reactant';
12+
import { unmountComponentAtNode, render } from 'reactant-web';
13+
import { act } from '../../../scripts/jest/act';
14+
import { LastAction } from 'reactant-last-action';
15+
import {
1316
createSharedApp,
1417
delegate,
1518
PortDetector,
16-
optional,
1719
mockPairTransports,
1820
fork,
1921
} from '..';

packages/reactant-share/test/router.test.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,19 @@
44
/* eslint-disable no-promise-executor-return */
55
/* eslint-disable jsx-a11y/anchor-is-valid */
66
import React, { FunctionComponent, PropsWithChildren } from 'react';
7-
import { unmountComponentAtNode, render, Switch, Route } from 'reactant-web';
8-
import type { History, LocationListener } from 'history';
9-
import { act } from '../../../scripts/jest/act';
107
import {
118
injectable,
129
state,
1310
action,
1411
ViewModule,
1512
useConnector,
1613
subscribe,
14+
optional,
15+
} from 'reactant';
16+
import { unmountComponentAtNode, render, Switch, Route } from 'reactant-web';
17+
import type { History, LocationListener } from 'history';
18+
import { act } from '../../../scripts/jest/act';
19+
import {
1720
createSharedApp,
1821
delegate,
1922
PortDetector,
@@ -28,7 +31,6 @@ import {
2831
StorageOptions,
2932
IStorageOptions,
3033
Storage,
31-
optional,
3234
} from '..';
3335
import { MemoryStorage } from './MemoryStorage';
3436

packages/reactant-share/test/storage.test.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,27 @@
33
/* eslint-disable @typescript-eslint/no-explicit-any */
44
/* eslint-disable no-promise-executor-return */
55
import React from 'react';
6-
import { unmountComponentAtNode, render } from 'reactant-web';
7-
import { act } from '../../../scripts/jest/act';
86
import {
97
injectable,
108
state,
119
action,
1210
ViewModule,
1311
useConnector,
1412
subscribe,
13+
optional,
14+
computed,
15+
watch,
16+
} from 'reactant';
17+
import { unmountComponentAtNode, render } from 'reactant-web';
18+
import { act } from '../../../scripts/jest/act';
19+
import {
1520
createSharedApp,
1621
delegate,
1722
PortDetector,
18-
optional,
1923
Storage,
2024
StorageOptions,
2125
IStorageOptions,
2226
mockPairTransports,
23-
computed,
24-
watch,
2527
} from '..';
2628
import { MemoryStorage } from './MemoryStorage';
2729

0 commit comments

Comments
 (0)