Skip to content

Commit

Permalink
test: waitTime改为sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
caijf committed Aug 24, 2023
1 parent 07445b1 commit 04d4290
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 4 additions & 3 deletions test/ajax.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/**
* @jest-environment jsdom
*/
import { ajax, waitTime } from '../src';
import { sleep } from 'ut2';
import { ajax } from '../src';

describe('ajax', () => {
enum ResponseMethod {
Expand Down Expand Up @@ -33,9 +34,9 @@ describe('ajax', () => {
} else if (resMethod === ResponseMethod.Timeout) {
methods.timeout();
} else {
await waitTime(100);
await sleep(100);
methods.progress?.();
await waitTime(100);
await sleep(100);
methods.progress?.();

methods.load();
Expand Down
9 changes: 5 additions & 4 deletions test/download.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/**
* @jest-environment jsdom
*/
import { download, waitTime } from '../src';
import { sleep } from 'ut2';
import { download } from '../src';

describe('download', () => {
// 参考: https://stackoverflow.com/questions/28584773/xmlhttprequest-testing-in-jest
Expand Down Expand Up @@ -31,9 +32,9 @@ describe('download', () => {
} else if (resMethod === ResponseMethod.Timeout) {
methods.timeout();
} else {
await waitTime(100);
await sleep(100);
methods.progress?.();
await waitTime(100);
await sleep(100);
methods.progress?.();

const res = {
Expand Down Expand Up @@ -140,7 +141,7 @@ describe('download', () => {
await download('/test.txt', {
dataType: 'url',
transformRequest: async (options) => {
await waitTime(100);
await sleep(100);
return {
...options,
method: 'post',
Expand Down

0 comments on commit 04d4290

Please sign in to comment.