import sinon from 'sinon';

import { assert } from '~/test/utils';

import { delay } from './delay';

jest.useFakeTimers();

describe('delay', () => {
  it('delay', () => {
    const callback = sinon.spy();
    delay(10).then(callback);
    assert.notCalled(callback);
    jest.runAllTimers();
    expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function), 10);
    assert.calledOnce(callback);
  });
});
