test: fix types for mock router

This commit is contained in:
satyajit.happy
2019-07-29 00:52:07 +02:00
parent 571c513eae
commit 04483a4f1b
3 changed files with 13 additions and 6 deletions

View File

@@ -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() {

View File

@@ -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 };

View File

@@ -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() {