felangel / bloc.js

A predictable state management library that helps implement the BLoC design pattern in JavaScript
https://bloclibrary.dev
190 stars 22 forks source link

[Question] How to proper test bloc.js #31

Closed Lonli-Lokli closed 4 years ago

Lonli-Lokli commented 4 years ago

As a continuation of previous issue, There some async blocs.

What are the possible ways to write verification tests that with the given initial state and input event I will get known number of output states, ended with some specific one?

felangel commented 4 years ago

Hi @Lonli-Lokli 👋 Thanks for opening an issue!

You can check out the bloc tests at https://github.com/felangel/bloc.js/blob/89807106ff3b8fc83fd5db3810f5d13a7118ffc4/packages/bloc/test/bloc.test.ts#L75 for an example. Let me know if that helps 👍

Lonli-Lokli commented 4 years ago

Thanks! So with your proposal it's required to complete the bloc stream.

felangel commented 4 years ago

@Lonli-Lokli yup so that you know for sure that no more states are emitted 👍