Skip to content

Commit

Permalink
test: correct types of unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JOU-amjs committed Dec 26, 2023
1 parent 6779621 commit 6e02ce4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
21 changes: 10 additions & 11 deletions test/setup.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { request } from '@dcloudio/types/uni-app/uni/base/request';
import { noop } from '../src/helper';
import { mockStorageContainer, uniDownloadConfig, uniRequestConfig, uniUploadConfig } from './utils';

interface UniMockMap {
request: typeof request;
request: UniNamespace.Uni['request'];
uploadFile: UniNamespace.Uni['uploadFile'];
downloadFile: UniNamespace.Uni['downloadFile'];
getStorageSync: UniNamespace.Uni['getStorageSync'];
Expand All @@ -25,7 +24,7 @@ const uniMockMap: UniMockMap = {
* 模拟实现uni.request
* @param options 请求参数
*/
request(options) {
request(options: UniApp.RequestOptions) {
uniRequestConfig.handler && uniRequestConfig.handler(options);
const timer = setTimeout(() => {
if (!uniRequestConfig.error && options.success) {
Expand Down Expand Up @@ -64,11 +63,11 @@ const uniMockMap: UniMockMap = {
* uni.uploadFile模拟实现
* @param options 上传参数
*/
uploadFile(options) {
uploadFile(options: UniApp.UploadFileOption) {
uniUploadConfig.handler && uniUploadConfig.handler(options);

let total = 200,
sent = 20;
const total = 200;
let sent = 20;
const progressTimer = setInterval(() => {
sent += (200 / responseDelay) * progressInterval;
progressHandler.upload({
Expand Down Expand Up @@ -101,7 +100,7 @@ const uniMockMap: UniMockMap = {
errMsg: 'uploadFile:fail abort'
});
},
onProgressUpdate(callback) {
onProgressUpdate(callback: any) {
progressHandler.upload = callback;
},
offProgressUpdate: noop,
Expand All @@ -114,11 +113,11 @@ const uniMockMap: UniMockMap = {
* uni.downloadFile模拟实现
* @param options 上传参数
*/
downloadFile(options) {
downloadFile(options: UniApp.DownloadFileOption) {
uniDownloadConfig.handler && uniDownloadConfig.handler(options);

let total = 200,
written = 20;
const total = 200;
let written = 20;
const progressTimer = setInterval(() => {
written += (200 / responseDelay) * progressInterval;
progressHandler.download({
Expand Down Expand Up @@ -150,7 +149,7 @@ const uniMockMap: UniMockMap = {
errMsg: 'downloadFile:fail abort'
});
},
onProgressUpdate(callback) {
onProgressUpdate(callback: any) {
progressHandler.download = callback;
},
offProgressUpdate: noop,
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"noImplicitAny": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"charset": "utf8",
"noEmitOnError": false,
"noUnusedLocals": true,
"noUnusedParameters": false,
Expand Down

0 comments on commit 6e02ce4

Please sign in to comment.