[arvados-workbench2] updated: 2.4.0-159-g760c35a4

git repository hosting git at public.arvados.org
Tue Jul 26 15:51:04 UTC 2022


Summary of changes:
 .../token-dialog/token-dialog.test.tsx             | 34 +++++++++++++++++++---
 1 file changed, 30 insertions(+), 4 deletions(-)

       via  760c35a45846cdcc0e1d796f0741d530e80bcd31 (commit)
      from  e2ac5434eb436b0e8ca8205dfe83d4ef1bcdd4c5 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 760c35a45846cdcc0e1d796f0741d530e80bcd31
Author: Stephen Smith <stephen at curii.com>
Date:   Tue Jul 26 11:50:39 2022 -0400

    16070: Add fake store to tests using code snippet.
    
    Arvados-DCO-1.1-Signed-off-by: Stephen Smith <stephen at curii.com>

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('<CurrentTokenDialog />', () => {
   let props;
   let wrapper;
+  let store;
 
   beforeEach(() => {
     props = {
@@ -33,11 +36,25 @@ describe('<CurrentTokenDialog />', () => {
       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(<TokenDialogComponent {...props} />);
+      wrapper = mount(
+        <Provider store={store}>
+          <TokenDialogComponent {...props} />
+        </Provider>
+      );
     });
 
     it('should include API host and token', () => {
@@ -51,7 +68,10 @@ describe('<CurrentTokenDialog />', () => {
 
       const someDate = '2140-01-01T00:00:00.000Z'
       props.tokenExpiration = new Date(someDate);
-      wrapper = mount(<TokenDialogComponent {...props} />);
+      wrapper = mount(
+        <Provider store={store}>
+          <TokenDialogComponent {...props} />
+        </Provider>);
       expect(wrapper.html()).toContain(props.tokenExpiration.toLocaleString());
     });
 
@@ -60,14 +80,20 @@ describe('<CurrentTokenDialog />', () => {
       expect(wrapper.html()).not.toContain('GET NEW TOKEN');
 
       props.canCreateNewTokens = true;
-      wrapper = mount(<TokenDialogComponent {...props} />);
+      wrapper = mount(
+        <Provider store={store}>
+          <TokenDialogComponent {...props} />
+        </Provider>);
       expect(wrapper.html()).toContain('GET NEW TOKEN');
     });
   });
 
   describe('copy to clipboard button', () => {
     beforeEach(() => {
-      wrapper = mount(<TokenDialogComponent {...props} />);
+      wrapper = mount(
+        <Provider store={store}>
+          <TokenDialogComponent {...props} />
+        </Provider>);
     });
 
     it('should copy API TOKEN to the clipboard', () => {

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list