Skip to content

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.

Notifications You must be signed in to change notification settings

mgechev/tic-tac

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tic-Tac 🍬

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.

How to use?

npm i tic-tac --save-dev
import tick from 'tic-tac';

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

About

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.

Resources

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published