mini_tea_test 0.1.0 copy "mini_tea_test: ^0.1.0" to clipboard
mini_tea_test: ^0.1.0 copied to clipboard

An extension to make mini_tea test easier.

Mini TEA test #

This package contains test utilities for Mini TEA.

We give you helper extensions to test your business logic and side effects.

Usage #

Update test

Just use extension method test. It expect some state, message to test, expected state and effects. If you omit expected effects, it will check that no effects are emitted.

void main() {
  test('Test update function', () {
    update.test(
      state: const State(),
      message: const UpdateTextEvent('Hello, World!'),
      expectedState: const State(
        input: 'Hello, World!',
      ),
      expectedEffects: [
        const SaveTextEffect(
          'Hello, World!',
        ),
      ],
    );
  });
}

Effect Handler test

Also, just use extension method test. It expect some effect and expected messages.

Because of the contract of the EffectHandler, you need to await result of test method.

void main() {
  test('Effect Handler test', () async {
    const handler = ExampleEffectHandler(
      // Here can be some mocks
    );
    await handler.test(
      effect: const CountTextHashEffect(
        '1',
        HashAlgorithm.md5,
      ),
      expectedMessages: [UpdateHashEvent(_md5OfOne)],
    );
  });
}
0
likes
0
points
6
downloads

Publisher

unverified uploader

Weekly Downloads

An extension to make mini_tea test easier.

Homepage
Repository (GitHub)
View/report issues

Topics

#state-management #architecture #unidirectional-data-flow #mvi

License

unknown (license)

Dependencies

meta, mini_tea, test

More

Packages that depend on mini_tea_test