Skip to content

Commit

Permalink
Add UI actions to Buttons module (#758)
Browse files Browse the repository at this point in the history
* add actions to Buttons module

* pr comments
  • Loading branch information
yebrahim authored and k8s-ci-robot committed Jan 31, 2019
1 parent 423f33c commit e29b181
Show file tree
Hide file tree
Showing 18 changed files with 516 additions and 604 deletions.
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

0 comments on commit e29b181

Please sign in to comment.