Skip to content

Commit 66d6095

Browse files
committed
test: adjust test project
1 parent d8a640c commit 66d6095

File tree

7 files changed

+29593
-34712
lines changed

7 files changed

+29593
-34712
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
example/*/**

.eslintrc.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ module.exports = {
2222
settings: {
2323
'import/resolver': {
2424
node: {
25-
extensions: ['.js', '.ts', '.tsx'],
25+
extensions: ['.jsx', '.ts', '.tsx'],
2626
},
2727
},
2828
},
29-
ignorePatterns: ["./example/*"],
3029
rules: {
3130
'react-hooks/rules-of-hooks': 'error',
3231
'react-hooks/exhaustive-deps': 'error',

example/package-lock.json

Lines changed: 29574 additions & 34697 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
"private": true,
77
"dependencies": {
88
"@material-ui/core": "^4.12.1",
9-
"react": "17.0.2",
9+
"react": "file:../node_modules/react",
1010
"react-dom": "^17.0.2",
11-
"react-scripts": "^4.0.3",
11+
"react-scripts": "file:../node_modules/react-scripts",
1212
"react-use-downloader": "file:.."
1313
},
1414
"scripts": {
15-
"start": "SKIP_PREFLIGHT_CHECK=true react-scripts start",
15+
"start": "react-scripts start",
1616
"build": "react-scripts build",
1717
"test": "react-scripts test --env=jsdom",
1818
"eject": "react-scripts eject"

example/src/App.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import {
32
Button,
43
Card,

example/src/index.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as React from 'react';
21
import ReactDOM from 'react-dom';
32

43
import App from './App';

src/index.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const resolver =
88
setPercentageCallback,
99
setErrorCallback,
1010
}: IResolverProps) =>
11-
(response: Response) => {
11+
(response: Response): Response => {
1212
if (!response.ok) {
1313
throw Error(`${response.status} ${response.type} ${response.statusText}`);
1414
}
@@ -24,7 +24,7 @@ export const resolver =
2424
contentEncoding ? 'x-file-size' : 'content-length'
2525
);
2626

27-
const total = parseInt(contentLength || "0", 10);
27+
const total = parseInt(contentLength || '0', 10);
2828

2929
setSize(() => total);
3030

@@ -69,7 +69,11 @@ export const resolver =
6969
return new Response(stream);
7070
};
7171

72-
export const jsDownload = (data: Blob, filename: string, mime?: string) => {
72+
export const jsDownload = (
73+
data: Blob,
74+
filename: string,
75+
mime?: string
76+
): boolean | NodeJS.Timeout => {
7377
const blobData = [data];
7478
const blob = new Blob(blobData, {
7579
type: mime || 'application/octet-stream',
@@ -110,23 +114,25 @@ export default function useDownloader(): IUseDownloader {
110114
const [error, setError] = useState<TError>(null);
111115
const [isInProgress, setIsInProgress] = useState(false);
112116

113-
const controllerRef = useRef<null | ReadableStreamController<Uint8Array>>(null);
117+
const controllerRef = useRef<null | ReadableStreamController<Uint8Array>>(
118+
null
119+
);
114120

115121
const setPercentageCallback = useCallback(({ loaded, total }) => {
116122
const pct = Math.round((loaded / total) * 100);
117123

118124
setPercentage(() => pct);
119125
}, []);
120126

121-
const setErrorCallback = useCallback((error: Error) => {
127+
const setErrorCallback = useCallback((err: Error) => {
122128
const errorMap = {
123129
"Failed to execute 'enqueue' on 'ReadableStreamDefaultController': Cannot enqueue a chunk into an errored readable stream":
124130
'Download canceled',
125131
};
126132
setError(() => {
127-
const resolvedError = errorMap[error.message]
128-
? errorMap[error.message]
129-
: error.message;
133+
const resolvedError = errorMap[err.message]
134+
? errorMap[err.message]
135+
: err.message;
130136

131137
return { errorMessage: resolvedError };
132138
});

0 commit comments

Comments
 (0)