力皓 084c342a65 refactor: 兼容 propTypes 写错
refactor(test): 增加 dragon / host / designer 部分单测
2020-12-17 22:26:35 +08:00

22 lines
456 B
TypeScript

import '../../fixtures/disable-raf';
import { throttle } from '../../../src/builtin-simulator/utils/throttle';
const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));
const cb = jest.fn();
describe('throttle', () => {
it('simple', async () => {
const fn = throttle(cb, 1000);
fn();
expect(cb).toBeCalledTimes(1);
await delay(200);
fn();
await delay(400);
fn();
expect(cb).toBeCalledTimes(1);
});
});