class ProfileViewModel {
final StreamController<String> _body = StreamController.broadcast();
Stream<String> get body => _body.stream;
void onBodyEdited(String body) {
_body.add(body);
}
}
test('test', () {
final viewModel = ProfileViewModel();
expectLater(viewModel.body, emits('body'));
viewModel.onBodyEdited('body');
});
test('test', () {
final viewModel = ProfileViewModel();
expectLater(
viewModel.body,
emitsInOrder([
emits('body'),
emits('body2'),
]),
);
viewModel.onBodyEdited('body');
viewModel.onBodyEdited('body2');
});
test('test', () {
final viewModel = ProfileViewModel();
viewModel.body.listen(expectAsync1((v) {
expect(v, 'body');
}));
viewModel.onBodyEdited('body');
});
viewModel.body.listen(expectAsync1((v) {
expect(v, 'body');
}, count: 2));
void main() {
test('test', () {
final viewModel = ProfileViewModel();
expectLater(viewModel.body, emits('body'));
viewModel.onBodyEdited('body');
});
test('test', () {
final viewModel = ProfileViewModel();
expectLater(
viewModel.body,
emitsInOrder([
emits('body'),
emits('body2'),
]),
);
viewModel.onBodyEdited('body');
viewModel.onBodyEdited('body2');
});
test('test', () {
final viewModel = ProfileViewModel();
viewModel.body.listen(expectAsync1((v) {
expect(v, 'body');
}));
viewModel.onBodyEdited('body');
});
}