fast_rx_test 0.1.0 fast_rx_test: ^0.1.0 copied to clipboard
Testing utilities for fast_rx. Check for valid RxObject registration.
Testing utilities for fast_rx
Features #
Method | Use-case |
---|---|
expectRxRegistration | Check for valid registration with the RxNotifier |
Getting started #
See fast_rx
Usage #
import 'package:fast_rx/fast_rx.dart';
import 'package:fast_rx_test/fast_rx_test.dart';
import 'package:flutter_test/flutter_test.dart';
import 'rx_tuple.dart';
void main() {
test('RxObject notifications', () {
final rx = Tuple(1, 2).rx;
expect(
rx.stream,
emitsInOrder(
[
Tuple(1, 2),
Tuple(2, 2),
Tuple(2, 3),
],
),
);
// Notify of the initial value
rx.notify();
// Update the value
rx.item1 = 2;
// Should not notify
rx.item2 = 2;
rx.item2 = 3;
// RxObject.value setter should throw if used
expect(
// ignore: invalid_use_of_protected_member
() => rx.value = Tuple(0, 0),
throwsA(isA<RxObjectValueIsReadOnly>()),
);
});
test('RxObject registration', () {
final rx = Tuple(1, 2).rx;
expectRxRegistration(
rx,
shouldRegister: [
() => rx.item1,
() => rx.item2,
],
shouldNotRegister: [
() => rx.item1 = 3,
() => rx.item2 = 3,
],
);
});
}
Additional information #
See fast_ui for more information