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

A package to make feature testing in mini_tea easier and more enjoyable.

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
150
points
38
downloads

Publisher

unverified uploader

Weekly Downloads

A package to make feature testing in mini_tea easier and more enjoyable.

Homepage
Repository (GitHub)
View/report issues

Topics

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

Documentation

API reference

License

MIT (license)

Dependencies

meta, mini_tea, test

More

Packages that depend on mini_tea_test