[ARVADOS-WORKBENCH2] updated: 1.4.1-102-g8d6d5f23

Git user git at public.curoverse.com
Fri Nov 15 21:25:19 UTC 2019


Summary of changes:
 src/store/auth/auth-action.test.ts | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

       via  8d6d5f23ab2e666fbb179093750d6b31280baede (commit)
      from  707b848245596bd4f25d497b45c1c3e501785ee4 (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 8d6d5f23ab2e666fbb179093750d6b31280baede
Author: Peter Amstutz <pamstutz at veritasgenetics.com>
Date:   Fri Nov 15 16:24:43 2019 -0500

    15803: Ensure mocks get cleaned up after test

diff --git a/src/store/auth/auth-action.test.ts b/src/store/auth/auth-action.test.ts
index 48f06d95..f721e760 100644
--- a/src/store/auth/auth-action.test.ts
+++ b/src/store/auth/auth-action.test.ts
@@ -2,8 +2,7 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import { authReducer, AuthState } from "./auth-reducer";
-import { AuthAction, initAuth } from "./auth-action";
+import { initAuth } from "./auth-action";
 import { API_TOKEN_KEY } from "~/services/auth-service/auth-service";
 
 import 'jest-localstorage-mock';
@@ -13,13 +12,14 @@ import createBrowserHistory from "history/createBrowserHistory";
 import { mockConfig } from '~/common/config';
 import { ApiActions } from "~/services/api/api-actions";
 import { ACCOUNT_LINK_STATUS_KEY } from '~/services/link-account-service/link-account-service';
-import axios from "axios";
+import Axios from "axios";
 import MockAdapter from "axios-mock-adapter";
 import { ImportMock } from 'ts-mock-imports';
 import * as servicesModule from "~/services/services";
 
 describe('auth-actions', () => {
-    const axiosMock = new MockAdapter(axios);
+    const axiosInst = Axios.create({ headers: {} });
+    const axiosMock = new MockAdapter(axiosInst);
 
     let store: RootStore;
     let services: ServiceRepository;
@@ -27,12 +27,18 @@ describe('auth-actions', () => {
         progressFn: (id: string, working: boolean) => { },
         errorFn: (id: string, message: string) => { }
     };
+    let importMocks: any[];
 
     beforeEach(() => {
         axiosMock.reset();
-        services = createServices(mockConfig({}), actions, axios);
+        services = createServices(mockConfig({}), actions, axiosInst);
         store = configureStore(createBrowserHistory(), services);
         localStorage.clear();
+        importMocks = [];
+    });
+
+    afterEach(() => {
+        importMocks.map(m => m.restore());
     });
 
     it('should initialise state with user and api token from local storage', (done) => {
@@ -51,7 +57,7 @@ describe('auth-actions', () => {
                 prefs: {}
             });
 
-        ImportMock.mockFunction(servicesModule, 'createServices', services);
+        importMocks.push(ImportMock.mockFunction(servicesModule, 'createServices', services));
 
         // Only test the case when a link account operation is not being cancelled
         sessionStorage.setItem(ACCOUNT_LINK_STATUS_KEY, "0");
@@ -70,7 +76,7 @@ describe('auth-actions', () => {
             if (auth.apiToken === "token" &&
                 auth.sessions.length === 2 &&
                 auth.sessions[0].status === 2 &&
-                auth.sessions[1].status === 2 
+                auth.sessions[1].status === 2
             ) {
                 try {
                     expect(auth).toEqual({

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list