mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-04-28 12:25:21 +08:00
test: fix types for mock router
This commit is contained in:
@@ -138,7 +138,10 @@ it('handle dispatching with ref', () => {
|
||||
|
||||
function CurrentChildRouter(options: DefaultRouterOptions) {
|
||||
const CurrentMockRouter = MockRouter(options);
|
||||
const ChildRouter: Router<NavigationState, MockActions> = {
|
||||
const ChildRouter: Router<
|
||||
NavigationState,
|
||||
MockActions | { type: 'REVERSE' }
|
||||
> = {
|
||||
...CurrentMockRouter,
|
||||
|
||||
shouldActionChangeFocus() {
|
||||
|
||||
@@ -6,9 +6,7 @@ import {
|
||||
DefaultRouterOptions,
|
||||
} from '../../types';
|
||||
|
||||
export type MockActions = CommonAction & {
|
||||
type: 'NOOP' | 'REVERSE' | 'UPDATE';
|
||||
};
|
||||
export type MockActions = CommonAction | { type: 'NOOP' | 'UPDATE' };
|
||||
|
||||
export const MockRouterKey = { current: 0 };
|
||||
|
||||
|
||||
@@ -14,7 +14,10 @@ beforeEach(() => (MockRouterKey.current = 0));
|
||||
it("lets parent handle the action if child didn't", () => {
|
||||
function CurrentRouter(options: DefaultRouterOptions) {
|
||||
const CurrentMockRouter = MockRouter(options);
|
||||
const ParentRouter: Router<NavigationState, MockActions> = {
|
||||
const ParentRouter: Router<
|
||||
NavigationState,
|
||||
MockActions | { type: 'REVERSE' }
|
||||
> = {
|
||||
...CurrentMockRouter,
|
||||
|
||||
getStateForAction(state, action) {
|
||||
@@ -98,7 +101,10 @@ it("lets children handle the action if parent didn't", () => {
|
||||
|
||||
function CurrentChildRouter(options: DefaultRouterOptions) {
|
||||
const CurrentMockRouter = MockRouter(options);
|
||||
const ChildRouter: Router<NavigationState, MockActions> = {
|
||||
const ChildRouter: Router<
|
||||
NavigationState,
|
||||
MockActions | { type: 'REVERSE' }
|
||||
> = {
|
||||
...CurrentMockRouter,
|
||||
|
||||
shouldActionChangeFocus() {
|
||||
|
||||
Reference in New Issue
Block a user