gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-merchant-backoffice] branch master updated: fix lint


From: gnunet
Subject: [taler-merchant-backoffice] branch master updated: fix lint
Date: Tue, 18 May 2021 22:35:47 +0200

This is an automated email from the git hooks/post-receive script.

sebasjm pushed a commit to branch master
in repository merchant-backoffice.

The following commit(s) were added to refs/heads/master by this push:
     new a275341  fix lint
a275341 is described below

commit a275341ee45123f067c5e14165046dabd51f6e3a
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Tue May 18 17:17:16 2021 -0300

    fix lint
---
 .../src/components/exception/AsyncButton.tsx        | 21 +++++++++++++++++++++
 packages/frontend/src/hooks/async.ts                |  2 +-
 packages/frontend/src/hooks/backend.ts              | 11 ++++++++++-
 packages/frontend/src/hooks/index.ts                |  3 ++-
 .../src/paths/instance/transfers/list/Table.tsx     |  4 ++--
 .../frontend/tests/hooks/swr/order-create.test.tsx  |  2 ++
 .../tests/hooks/swr/order-pagination.test.tsx       |  2 ++
 .../tests/hooks/swr/product-create.test.tsx         |  2 ++
 .../tests/hooks/swr/product-delete.test.tsx         |  3 +++
 .../tests/hooks/swr/product-details-update.test.tsx |  2 ++
 .../tests/hooks/swr/product-update.test.tsx         |  2 ++
 11 files changed, 49 insertions(+), 5 deletions(-)

diff --git a/packages/frontend/src/components/exception/AsyncButton.tsx 
b/packages/frontend/src/components/exception/AsyncButton.tsx
index b7472fd..95e4e72 100644
--- a/packages/frontend/src/components/exception/AsyncButton.tsx
+++ b/packages/frontend/src/components/exception/AsyncButton.tsx
@@ -1,3 +1,24 @@
+/*
+ This file is part of GNU Taler
+ (C) 2021 Taler Systems S.A.
+
+ GNU Taler is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ GNU Taler; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
+ */
+
+/**
+*
+* @author Sebastian Javier Marchano (sebasjm)
+*/
+
 import { ComponentChildren, h } from "preact";
 import { LoadingModal } from "../modal";
 import { useAsync } from "../../hooks/async";
diff --git a/packages/frontend/src/hooks/async.ts 
b/packages/frontend/src/hooks/async.ts
index 4e2ca10..fd55004 100644
--- a/packages/frontend/src/hooks/async.ts
+++ b/packages/frontend/src/hooks/async.ts
@@ -73,4 +73,4 @@ export function useAsync<T>(fn?: (...args: any) => 
Promise<T>, { slowTolerance:
     isLoading,
     error
   };
-};
+}
diff --git a/packages/frontend/src/hooks/backend.ts 
b/packages/frontend/src/hooks/backend.ts
index 0c86d89..8fad397 100644
--- a/packages/frontend/src/hooks/backend.ts
+++ b/packages/frontend/src/hooks/backend.ts
@@ -192,6 +192,15 @@ export function cancelPendingRequest() {
   source = CancelToken.source()
 }
 
+let allowAxiosCancellation = false
+/**
+ * Jest mocking seems to break when using the cancelToken property.
+ * Using this workaround when testing while finding the correct solution
+ */
+export function setAxiosRequestAsTestingEnvironment() {
+  allowAxiosCancellation = true
+}
+
 export async function request<T>(url: string, options: RequestOptions = {}): 
Promise<HttpResponseOk<T>> {
   const headers = options.token ? { Authorization: `Bearer ${options.token}` } 
: undefined
 
@@ -200,7 +209,7 @@ export async function request<T>(url: string, options: 
RequestOptions = {}): Pro
       url,
       responseType: 'json',
       headers,
-      cancelToken: source.token,
+      cancelToken: !allowAxiosCancellation? source.token : undefined,
       method: options.method || 'get',
       data: options.data,
       params: options.params,
diff --git a/packages/frontend/src/hooks/index.ts 
b/packages/frontend/src/hooks/index.ts
index d170233..b443898 100644
--- a/packages/frontend/src/hooks/index.ts
+++ b/packages/frontend/src/hooks/index.ts
@@ -116,7 +116,8 @@ export function useNotNullLocalStorage(key: string, 
initialValue: string): [stri
  * @returns activator and subscriber, undefined activator means that there is 
not subscriber
  */
 export function useListener<T, R = any>(action: (r: T) => Promise<R>): 
[undefined | (() => Promise<R>), (listener?: () => T) => void] {
-  const [state, setState] = useState<{ toBeRan?: () => Promise<R> }>({})
+  type RunnerHandler = { toBeRan?: () => Promise<R> }
+  const [state, setState] = useState<RunnerHandler>({})
 
   /**
    * subscriber will receive a method that will be call when the activator runs
diff --git a/packages/frontend/src/paths/instance/transfers/list/Table.tsx 
b/packages/frontend/src/paths/instance/transfers/list/Table.tsx
index c91b28a..ad7248f 100644
--- a/packages/frontend/src/paths/instance/transfers/list/Table.tsx
+++ b/packages/frontend/src/paths/instance/transfers/list/Table.tsx
@@ -126,7 +126,7 @@ function Table({ instances, onLoadMoreAfter, onDelete, 
onLoadMoreBefore, hasMore
             <th><Translate>Confirmed</Translate></th>
             <th><Translate>Verified</Translate></th>
             <th><Translate>Executed at</Translate></th>
-            <th></th>
+            <th />
           </tr>
         </thead>
         <tbody>
@@ -140,7 +140,7 @@ function Table({ instances, onLoadMoreAfter, onDelete, 
onLoadMoreBefore, hasMore
               <td>{i.verified ? i18n`yes` : i18n`no`}</td>
               <td>{i.execution_time ? (i.execution_time.t_ms == 'never' ? 
i18n`never` : format(i.execution_time.t_ms, 'yyyy/MM/dd HH:mm:ss')) : 
i18n`unknown`}</td>
               <td>
-                {i.verified === undefined ? <button class="button is-danger 
is-small" onClick={() => onDelete(i) }>Delete</button> : undefined }
+                {i.verified === undefined ? <button class="button is-danger 
is-small" onClick={() => onDelete(i)}>Delete</button> : undefined}
               </td>
             </tr>
           })}
diff --git a/packages/frontend/tests/hooks/swr/order-create.test.tsx 
b/packages/frontend/tests/hooks/swr/order-create.test.tsx
index d80f815..00d39fa 100644
--- a/packages/frontend/tests/hooks/swr/order-create.test.tsx
+++ b/packages/frontend/tests/hooks/swr/order-create.test.tsx
@@ -24,9 +24,11 @@ import * as axios from 'axios';
 import * as backend from '../../../src/context/backend';
 import * as instance from '../../../src/context/instance';
 import { MerchantBackend } from '../../../src/declaration';
+import { setAxiosRequestAsTestingEnvironment } from 
'../../../src/hooks/backend';
 import { useInstanceOrders, useOrderAPI } from '../../../src/hooks/order';
 import { simulateBackendResponse } from '../../util'
 
+setAxiosRequestAsTestingEnvironment()
 
 jest.mock('axios');
 
diff --git a/packages/frontend/tests/hooks/swr/order-pagination.test.tsx 
b/packages/frontend/tests/hooks/swr/order-pagination.test.tsx
index f99b52d..be4193a 100644
--- a/packages/frontend/tests/hooks/swr/order-pagination.test.tsx
+++ b/packages/frontend/tests/hooks/swr/order-pagination.test.tsx
@@ -24,9 +24,11 @@ import * as axios from 'axios';
 import * as backend from '../../../src/context/backend';
 import * as instance from '../../../src/context/instance';
 import { MerchantBackend } from '../../../src/declaration';
+import { setAxiosRequestAsTestingEnvironment } from 
'../../../src/hooks/backend';
 import { useInstanceOrders } from '../../../src/hooks/order';
 import { simulateBackendResponse } from '../../util'
 
+setAxiosRequestAsTestingEnvironment()
 
 jest.mock('axios');
 
diff --git a/packages/frontend/tests/hooks/swr/product-create.test.tsx 
b/packages/frontend/tests/hooks/swr/product-create.test.tsx
index 318c93b..fa04148 100644
--- a/packages/frontend/tests/hooks/swr/product-create.test.tsx
+++ b/packages/frontend/tests/hooks/swr/product-create.test.tsx
@@ -24,9 +24,11 @@ import * as axios from 'axios';
 import * as backend from '../../../src/context/backend';
 import * as instance from '../../../src/context/instance';
 import { MerchantBackend } from '../../../src/declaration';
+import { setAxiosRequestAsTestingEnvironment } from 
'../../../src/hooks/backend';
 import { useInstanceProducts, useProductAPI } from 
'../../../src/hooks/product';
 import { simulateBackendResponse } from '../../util'
 
+setAxiosRequestAsTestingEnvironment()
 
 jest.mock('axios');
 
diff --git a/packages/frontend/tests/hooks/swr/product-delete.test.tsx 
b/packages/frontend/tests/hooks/swr/product-delete.test.tsx
index 7fdf24b..7de00bf 100644
--- a/packages/frontend/tests/hooks/swr/product-delete.test.tsx
+++ b/packages/frontend/tests/hooks/swr/product-delete.test.tsx
@@ -28,6 +28,9 @@ import { simulateBackendResponse } from '../../util'
 
 // eslint-disable-next-line @typescript-eslint/no-unused-vars
 import * as axios from 'axios';
+import { setAxiosRequestAsTestingEnvironment } from 
'../../../src/hooks/backend';
+
+setAxiosRequestAsTestingEnvironment()
 
 jest.mock('axios');
 axios.default
diff --git a/packages/frontend/tests/hooks/swr/product-details-update.test.tsx 
b/packages/frontend/tests/hooks/swr/product-details-update.test.tsx
index eb4e2ed..aa1cd5d 100644
--- a/packages/frontend/tests/hooks/swr/product-details-update.test.tsx
+++ b/packages/frontend/tests/hooks/swr/product-details-update.test.tsx
@@ -24,9 +24,11 @@ import * as axios from 'axios';
 import * as backend from '../../../src/context/backend';
 import * as instance from '../../../src/context/instance';
 import { MerchantBackend } from '../../../src/declaration';
+import { setAxiosRequestAsTestingEnvironment } from 
'../../../src/hooks/backend';
 import { useProductAPI, useProductDetails } from '../../../src/hooks/product';
 import { simulateBackendResponse } from '../../util'
 
+setAxiosRequestAsTestingEnvironment()
 
 jest.mock('axios');
 
diff --git a/packages/frontend/tests/hooks/swr/product-update.test.tsx 
b/packages/frontend/tests/hooks/swr/product-update.test.tsx
index daaafbd..76ad29c 100644
--- a/packages/frontend/tests/hooks/swr/product-update.test.tsx
+++ b/packages/frontend/tests/hooks/swr/product-update.test.tsx
@@ -24,9 +24,11 @@ import * as axios from 'axios';
 import * as backend from '../../../src/context/backend';
 import * as instance from '../../../src/context/instance';
 import { MerchantBackend } from '../../../src/declaration';
+import { setAxiosRequestAsTestingEnvironment } from 
'../../../src/hooks/backend';
 import { useInstanceProducts, useProductAPI } from 
'../../../src/hooks/product';
 import { simulateBackendResponse } from '../../util'
 
+setAxiosRequestAsTestingEnvironment()
 
 jest.mock('axios');
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]