testController<T> function

  1. @isTest
void testController<T>(
  1. String description,
  2. void callback(
    1. T
    ), {
  3. required T controller,
  4. void onInit(
    1. T
    )?,
  5. void onReady(
    1. T
    )?,
  6. void onClose(
    1. T
    )?,
})

Implementation

@isTest
void testController<T>(
  String description,
  void Function(T) callback, {
  required T controller,
  void Function(T)? onInit,
  void Function(T)? onReady,
  void Function(T)? onClose,
}) {
  test(description, () {
    onInit?.call(controller);
    SchedulerBinding.instance?.addPostFrameCallback((f) {
      onReady?.call(controller);
    });
    callback(controller);
    onClose?.call(controller);
  });
}