From: Stephen Smith Date: Tue, 26 Jul 2022 15:50:39 +0000 (-0400) Subject: 16070: Add fake store to tests using code snippet. X-Git-Tag: 2.5.0~45^2~1 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/760c35a45846cdcc0e1d796f0741d530e80bcd31 16070: Add fake store to tests using code snippet. Arvados-DCO-1.1-Signed-off-by: Stephen Smith --- diff --git a/src/views-components/token-dialog/token-dialog.test.tsx b/src/views-components/token-dialog/token-dialog.test.tsx index d2ff77e3..400bb1e6 100644 --- a/src/views-components/token-dialog/token-dialog.test.tsx +++ b/src/views-components/token-dialog/token-dialog.test.tsx @@ -16,6 +16,8 @@ import { mount, configure } from 'enzyme'; import Adapter from 'enzyme-adapter-react-16'; import CopyToClipboard from 'react-copy-to-clipboard'; import { TokenDialogComponent } from './token-dialog'; +import { combineReducers, createStore } from 'redux'; +import { Provider } from 'react-redux'; configure({ adapter: new Adapter() }); @@ -24,6 +26,7 @@ jest.mock('toggle-selection', () => () => () => null); describe('', () => { let props; let wrapper; + let store; beforeEach(() => { props = { @@ -33,11 +36,25 @@ describe('', () => { open: true, dispatch: jest.fn(), }; + + const initialAuthState = { + localCluster: "zzzzz", + remoteHostsConfig: {}, + sessions: {}, + }; + + store = createStore(combineReducers({ + auth: (state: any = initialAuthState, action: any) => state, + })); }); describe('Get API Token dialog', () => { beforeEach(() => { - wrapper = mount(); + wrapper = mount( + + + + ); }); it('should include API host and token', () => { @@ -51,7 +68,10 @@ describe('', () => { const someDate = '2140-01-01T00:00:00.000Z' props.tokenExpiration = new Date(someDate); - wrapper = mount(); + wrapper = mount( + + + ); expect(wrapper.html()).toContain(props.tokenExpiration.toLocaleString()); }); @@ -60,14 +80,20 @@ describe('', () => { expect(wrapper.html()).not.toContain('GET NEW TOKEN'); props.canCreateNewTokens = true; - wrapper = mount(); + wrapper = mount( + + + ); expect(wrapper.html()).toContain('GET NEW TOKEN'); }); }); describe('copy to clipboard button', () => { beforeEach(() => { - wrapper = mount(); + wrapper = mount( + + + ); }); it('should copy API TOKEN to the clipboard', () => {