Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UI actions to Buttons module #758

Merged
merged 2 commits into from
Jan 31, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions frontend/src/TestUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
import * as React from 'react';
// @ts-ignore
import createRouterContext from 'react-router-test-context';
import { PageProps, Page } from './pages/Page';
import { mount, ReactWrapper } from 'enzyme';
import { object } from 'prop-types';
import { match } from 'react-router';

export default class TestUtils {
/**
Expand Down Expand Up @@ -54,4 +56,27 @@ export default class TestUtils {
};
});
}

// tslint:disable-next-line:variable-name
public static generatePageProps(PageElement: new (x: PageProps) => Page<any, any>,
location: Location, matchValue: match,
historyPushSpy: jest.SpyInstance | null, updateBannerSpy: jest.SpyInstance,
updateDialogSpy: jest.SpyInstance, updateToolbarSpy: jest.SpyInstance,
updateSnackbarSpy: jest.SpyInstance): PageProps {
const pageProps = {
history: { push: historyPushSpy } as any,
location: location as any,
match: matchValue,
toolbarProps: { actions: [], breadcrumbs: [], pageTitle: '' },
updateBanner: updateBannerSpy as any,
updateDialog: updateDialogSpy as any,
updateSnackbar: updateSnackbarSpy as any,
updateToolbar: updateToolbarSpy as any,
} as PageProps;
pageProps.toolbarProps = new PageElement(pageProps).getInitialToolbarState();
// The toolbar spy gets called in the getInitialToolbarState method, reset it
// in order to simplify tests
updateToolbarSpy.mockReset();
return pageProps;
}
}
Loading