tick-it
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Tick IT!

A function which pushes a new task into the queue in order to provide convenient way to wait for completion of micro-tasks. It's quite useful for testing:

import tick from 'tick-it';
 
class Service {
  foo(promise) {
    promise.then(data => this.bar(data));
  }
 
  bar(data) {
    // do stuff
  }
}
 
describe('async module', () => {
  let service;
 
  beforeEach(() => {
    service = new Service();
  });
 
  it('should work', async () => {
    const spy = spyOn(service, 'bar');
    service.foo(Promise.resolve({ foo: 'bar' }));
 
    await tick();
 
    expect(spy).toHaveBeenCalled();
  });
});

License

MIT

Package Sidebar

Install

npm i tick-it

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • mgechev