test: add is-promise testcase and fix test problem

pull/13/head
moonrailgun
parent 6e65712de6
commit edaaf220b4

@ -78,7 +78,7 @@ export function buildStorage(backend: any) {
} }
return res; return res;
}, },
remove: async (key) => { remove: async (key: string) => {
await storage.remove({ key }); await storage.remove({ key });
}, },
/** /**

@ -74,7 +74,7 @@ export const FastForm: React.FC<FastFormProps> = React.memo((props) => {
{...fieldMeta} {...fieldMeta}
value={value} value={value}
error={error} error={error}
onChange={(val) => setFieldValue(fieldName, val)} onChange={(val: any) => setFieldValue(fieldName, val)}
/> />
); );
} }

@ -1,5 +1,5 @@
import { DependencyList, useEffect } from 'react'; import { DependencyList, useEffect } from 'react';
import { FunctionReturningPromise } from '../types'; import type { FunctionReturningPromise } from '../types';
import { useAsyncFn } from './useAsyncFn'; import { useAsyncFn } from './useAsyncFn';
// Reference: https://github.com/streamich/react-use/blob/master/src/useAsync.ts // Reference: https://github.com/streamich/react-use/blob/master/src/useAsync.ts

@ -0,0 +1 @@
declare module 'str2int';

@ -0,0 +1,16 @@
import { isPromise } from '../is-promise';
describe('isPromise', () => {
test.each([
[Promise.resolve(), true],
['str', false],
[123, false],
[[], false],
[{}, false],
[Symbol('sym'), false],
[undefined, false],
[null, false],
])('%s => %s', (input, should) => {
expect(isPromise(input)).toBe(should);
});
});

@ -2,6 +2,10 @@ import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime'; // 导入插件 import relativeTime from 'dayjs/plugin/relativeTime'; // 导入插件
import 'dayjs/locale/zh-cn'; // 导入本地化语言 import 'dayjs/locale/zh-cn'; // 导入本地化语言
/**
* Reference: https://day.js.org/
*/
dayjs.extend(relativeTime); dayjs.extend(relativeTime);
dayjs.locale('zh-cn'); dayjs.locale('zh-cn');

Loading…
Cancel
Save