[Test] optimize async cases (#1232)

This commit is contained in:
neverland
2018-06-06 20:13:24 +08:00
committed by GitHub
parent 25bd67e8f1
commit 74aa001bb6
10 changed files with 127 additions and 137 deletions

View File

@@ -1,6 +1,7 @@
import deepClone from '../deep-clone';
import { isAndroid, isDef, camelize, get } from '..';
import { raf, cancel } from '../raf';
import { later } from '../../../test/utils';
test('deepClone', () => {
const a = { foo: 0 };
@@ -43,13 +44,11 @@ test('isAndroid', () => {
expect(isAndroid()).toBeFalsy();
});
test('raf', (done) => {
test('raf', async() => {
const spy = jest.fn();
raf(spy);
setTimeout(() => {
expect(spy.mock.calls.length).toBe(1);
cancel(1);
done();
}, 50);
await later(50);
expect(spy.mock.calls.length).toBe(1);
cancel(1);
});