testRxNotifier<S extends RxNotifier<T>, T> function

  1. @isTest
void testRxNotifier<S extends RxNotifier<T>, T>(
  1. String description, {
  2. required S build(),
  3. FutureOr<void> setUp()?,
  4. T seed()?,
  5. FutureOr<void> act(
    1. S notifier
    )?,
  6. Duration? wait,
  7. int skip = 0,
  8. List<T> expect()?,
  9. FutureOr<void> verify(
    1. S notifier
    )?,
  10. Object errors()?,
  11. FutureOr<void> tearDown()?,
  12. dynamic tags,
})

Defines a test case for a RxNotifier object.

The testRxNotifier function defines a test case for a specific RxNotifier object, which represents a reactive state container. It allows you to set up the initial state, perform actions on the state, and verify the expected behavior and outcomes.

The testRxNotifier function takes various parameters to configure the test case, such as the test description, setup and teardown functions, actions to perform on the state, expected outcomes, and error handling. It uses the test library from the test package to define and run the actual test.

Example usage:

testRxNotifier<int>(
  'RxNotifier test case',
  build: () => RxNotifier<int>(0),
  act: (notifier) => notifier.value = 10,
  expect: () => [10],
);

In the above example, the testRxNotifier function is used to define a test case for an RxNotifier object that holds an integer value. The test case sets up the initial state, performs an action by assigning the value 10 to the state, and expects the state to have the value 10. The test case is then run using the test library.

The testRxNotifier function simplifies the testing of reactive state containers, allowing you to define clear and concise test cases that cover different scenarios and behaviors of the state.

Implementation

@isTest
void testRxNotifier<S extends RxNotifier<T>, T>(
  String description, {
  required S Function() build,
  FutureOr<void> Function()? setUp,
  T Function()? seed,
  FutureOr<void> Function(S notifier)? act,
  Duration? wait,
  int skip = 0,
  List<T> Function()? expect,
  FutureOr<void> Function(S notifier)? verify,
  Object Function()? errors,
  FutureOr<void> Function()? tearDown,
  dynamic tags,
}) {
  test.test(
    description,
    () async {
      await _rxNotifierTest<S, T>(
        setUp: setUp,
        build: build,
        seed: seed,
        act: act,
        wait: wait,
        skip: skip,
        expect: expect,
        verify: verify,
        errors: errors,
        tearDown: tearDown,
      );
    },
    tags: tags,
  );
}